Add local n-gram near match for OKF agent-kb reuse.
Sparse bigram cosine closes near-duplicate goal fragmentation; soft_match parents now judge ranked scored candidates instead of a flat task list. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f240bdf156
commit
ab8ea8438f
9 files changed
+427
-88
No files matched your search
+26
-9
@@ -936,19 +936,24 @@ Parse `SLUG: …` / `标识:…` after a soft-match REUSE decision.
|
||||
+ `goal`
|
||||
+ `tasks`
|
||||
|
||||
Short parent prompt: REUSE+SLUG or NEW only.
|
||||
Short parent prompt: REUSE+SLUG or NEW only. Candidates may include lexical `score` (prefer higher).
|
||||
|
||||
*`esc` = > json.parse text={"a":"\n\n--- goal ---\n","b":"\n\n--- candidate tasks (slug | title) ---\n","c":"\n\n--- how to act ---\nExact reuse miss. Reply with ONE protocol only:\nDECISION: REUSE\nSLUG: <exact-slug-from-list>\nor\nDECISION: NEW\nNo other prose.\n","nl":"\n","sep":" | "} *
|
||||
*`esc` = > json.parse text={"a":"\n\n--- goal ---\n","b":"\n\n--- candidate tasks (slug | title | score) ---\n","c":"\n\n--- how to act ---\nExact reuse miss; candidates are ranked by local n-gram score when present. Prefer higher scores. Reply with ONE protocol only:\nDECISION: REUSE\nSLUG: <exact-slug-from-list>\nor\nDECISION: NEW\nNo other prose.\n","nl":"\n","sep":" | ","sp":"score="} *
|
||||
*`a` = > json.get value=`esc` key=a *
|
||||
*`b` = > json.get value=`esc` key=b *
|
||||
*`c` = > json.get value=`esc` key=c *
|
||||
*`nl` = > json.get value=`esc` key=nl *
|
||||
*`sep` = > json.get value=`esc` key=sep *
|
||||
*`sp` = > json.get value=`esc` key=sp *
|
||||
*`lines` = > json.parse text=[] *
|
||||
- [`t`](`tasks`)
|
||||
*`slug` = > json.get value=`t` key=slug *
|
||||
*`title` = > json.get value=`t` key=title *
|
||||
*`row` = `slug` + `sep` + `title` *
|
||||
*`score` = > json.get value=`t` key=score *
|
||||
1. `score`
|
||||
*`row` = `slug` + `sep` + `title` + `sep` + `sp` + `score` *
|
||||
2. *
|
||||
*`row` = `slug` + `sep` + `title` *
|
||||
*`lines` = > json.append list=`lines` item=`row` *
|
||||
*`catalog` = > join value=`lines` sep=`nl` *
|
||||
*`p` = Soft-match: same task intent? *
|
||||
@@ -1408,6 +1413,8 @@ With `stream=True`, the model call uses SSE; `echo=True` prints delta text to st
|
||||
+ `optimize`=False
|
||||
+ `force`=False
|
||||
+ `soft_match`=False
|
||||
+ `near_match`=True
|
||||
+ `near_threshold`=0.78
|
||||
+ `promote`=True
|
||||
+ `kb_dir`=.marqdo/agent-kb
|
||||
+ `improve_every`=3
|
||||
@@ -1418,7 +1425,7 @@ With `stream=True`, the model call uses SSE; `echo=True` prints delta text to st
|
||||
|
||||
Multi-step with OKF agent-kb. Default workbook is `kb_dir/resources/<slug>.mq.md`. While task file count `< explore_n` and skill is not llm_free, force a new explore variant under `kb_dir/explore/<slug>/`. Code-first: llm_free hits skip parent LLM. File children return via `# main`; `plan` exposes that as `result`.
|
||||
|
||||
Non-hit path: optional `soft_match=True` parent REUSE/NEW; else **decompose** before first child spawn (`DECISION: RUN` / `CONTINUE`+patch / solidified `DONE`). Then `await` → revise loop. With `stream=True`, emit parent `delta` / `decision` / `tool_start`/`tool_end` / `round` / `done` on `events`. `echo=True` prints `plan:decompose` / `plan:await` / deltas. `trace=True` writes events to writeback slot `trace`. Quiet child subtasks stay quiet.
|
||||
Reuse lookup: exact → alias → canonicalize → optional local n-gram `near` when `near_match=True` and score ≥ `near_threshold`. Non-hit path: optional `soft_match=True` parent REUSE/NEW over ranked `agent_kb_near_match` candidates; else **decompose** before first child spawn (`DECISION: RUN` / `CONTINUE`+patch / solidified `DONE`). Then `await` → revise loop. With `stream=True`, emit parent `delta` / `decision` / `tool_start`/`tool_end` / `round` / `done` on `events`. `echo=True` prints `plan:decompose` / `plan:await` / deltas. `trace=True` writes events to writeback slot `trace`. Quiet child subtasks stay quiet.
|
||||
|
||||
*`tools` = > json.get value=`self` key=tools *
|
||||
*`cache` = miss*
|
||||
@@ -1437,7 +1444,7 @@ Non-hit path: optional `soft_match=True` parent REUSE/NEW; else **decompose** be
|
||||
2. `optimize`
|
||||
*`_` = 1*
|
||||
3. `reuse`
|
||||
*`hit` = > agent_kb_lookup kb_dir=`kb_dir` goal=`goal` tools=`tools` *
|
||||
*`hit` = > agent_kb_lookup kb_dir=`kb_dir` goal=`goal` tools=`tools` near_match=`near_match` near_threshold=`near_threshold` *
|
||||
1. `hit`
|
||||
*`match_kind` = > json.get value=`hit` key=match *
|
||||
1. `match_kind` == alias
|
||||
@@ -1446,9 +1453,13 @@ Non-hit path: optional `soft_match=True` parent REUSE/NEW; else **decompose** be
|
||||
*`cache_label` = soft-hit*
|
||||
*`hit_slug` = > json.get value=`hit` key=slug *
|
||||
> agent_kb_add_alias kb_dir=`kb_dir` slug=`hit_slug` alias=`goal`
|
||||
3. `match_kind` == soft
|
||||
3. `match_kind` == near
|
||||
*`cache_label` = soft-hit*
|
||||
4. *
|
||||
*`hit_slug` = > json.get value=`hit` key=slug *
|
||||
> agent_kb_add_alias kb_dir=`kb_dir` slug=`hit_slug` alias=`goal`
|
||||
4. `match_kind` == soft
|
||||
*`cache_label` = soft-hit*
|
||||
5. *
|
||||
*`cache_label` = hit*
|
||||
*`lf` = > json.get value=`hit` key=llm_free *
|
||||
1. `lf`
|
||||
@@ -1533,9 +1544,15 @@ Non-hit path: optional `soft_match=True` parent REUSE/NEW; else **decompose** be
|
||||
*`path` = None*
|
||||
2. *
|
||||
1. `soft_match`
|
||||
*`listed` = > agent_kb_list_tasks kb_dir=`kb_dir` *
|
||||
*`tasks` = > json.get value=`listed` key=tasks *
|
||||
*`near` = > agent_kb_near_match kb_dir=`kb_dir` goal=`goal` *
|
||||
*`tasks` = > json.get value=`near` key=candidates *
|
||||
*`tn` = > len value=`tasks` *
|
||||
1. `tn` < 1
|
||||
*`listed` = > agent_kb_list_tasks kb_dir=`kb_dir` *
|
||||
*`tasks` = > json.get value=`listed` key=tasks *
|
||||
*`tn` = > len value=`tasks` *
|
||||
2. *
|
||||
*`_` = 1*
|
||||
1. `tn` > 0
|
||||
*`soft_prompt` = > build_soft_match_prompt goal=`goal` tasks=`tasks` *
|
||||
*`model` = > json.get value=`self` key=model *
|
||||
|
||||
+4
-2
@@ -216,6 +216,8 @@ description: 文档驱动智能体 — 单步 / 多步;工具经 lib/子任务
|
||||
+ `优化`=False
|
||||
+ `强制`=False
|
||||
+ `软命中`=False
|
||||
+ `近义命中`=True
|
||||
+ `近义阈值`=0.78
|
||||
+ `晋升`=True
|
||||
+ `知识库目录`=.marqdo/agent-kb
|
||||
+ `改进周期`=3
|
||||
@@ -224,10 +226,10 @@ description: 文档驱动智能体 — 单步 / 多步;工具经 lib/子任务
|
||||
+ `打印增量`=False
|
||||
+ `轨迹`=False
|
||||
|
||||
多步工作簿默认写入 OKF `知识库目录/resources/<slug>.mq.md`;仅当传入 `工作簿目录` 时才用临时 runs。转发至英文 `agent.plan`。`流式` / `打印增量` / `轨迹` 对应 `stream` / `echo` / `trace`;`软命中` → `soft_match`。
|
||||
多步工作簿默认写入 OKF `知识库目录/resources/<slug>.mq.md`;仅当传入 `工作簿目录` 时才用临时 runs。转发至英文 `agent.plan`。`流式` / `打印增量` / `轨迹` 对应 `stream` / `echo` / `trace`;`软命中` → `soft_match`;`近义命中` / `近义阈值` → `near_match` / `near_threshold`。
|
||||
|
||||
*`model` = > json.get value=`self` key=model *
|
||||
*`tools` = > json.get value=`self` key=tools *
|
||||
*`standing` = > json.get value=`self` key=standing *
|
||||
*`en` = > agent.agent model=`model` tools=`tools` standing=`standing` *
|
||||
**> `en`.plan goal=`目标` workbook_dir=`工作簿目录` workbook=`工作簿` max_rounds=`最大轮次` confirm=`确认分解` writeback=`写回` skeleton=`骨架` reuse=`复用` optimize=`优化` force=`强制` soft_match=`软命中` promote=`晋升` kb_dir=`知识库目录` improve_every=`改进周期` explore_n=`探索次数` stream=`流式` echo=`打印增量` trace=`轨迹`**
|
||||
**> `en`.plan goal=`目标` workbook_dir=`工作簿目录` workbook=`工作簿` max_rounds=`最大轮次` confirm=`确认分解` writeback=`写回` skeleton=`骨架` reuse=`复用` optimize=`优化` force=`强制` soft_match=`软命中` near_match=`近义命中` near_threshold=`近义阈值` promote=`晋升` kb_dir=`知识库目录` improve_every=`改进周期` explore_n=`探索次数` stream=`流式` echo=`打印增量` trace=`轨迹`**
|
||||
Reference in new issue
Block a user