Skip to content

召回前用会话自己的模型改写查询 - #49

Open
forrestlinfeng wants to merge 6 commits into
mainfrom
feat/recall-query-rewrite-verify
Open

forrestlinfeng wants to merge 6 commits into
mainfrom
feat/recall-query-rewrite-verify

Conversation

@forrestlinfeng

@forrestlinfeng forrestlinfeng commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

背景

插件现在用题目前 400 字向 Hub 召回。金融、办公表格、业务流程、客服、法律 5 个门类的题,前 400 字是同一段模板,等于每题都发同一条查询。本 PR 在召回前把完整题目改写成一句检索查询。

改动

  1. 查询改写走会话自己的模型:通过 dsh 的 llm 服务,用当前 agent 的 provider / model 调一次,不再写死网关地址和模型,也不需要单独的 key。提示词与离线回放时一致。
  2. 以下情况回退到前 400 字查询:拿不到 llm 服务、agent 没有 provider/model,或改写失败(报错、超时 12 秒、返回空)。失败原因写进召回日志的 rewrite_error,并输出 ctx.logger.warn。
  3. 续跑轮:改写时读"会话首条提示 + 本轮提示",避免 "Continue with the task…" 这类提示被改写成无关查询。
  4. 去掉注入前复核:前 10 个候选的逐个复核、最多注入 5 个资产、网关重试都已删除。注入行为与 main 相同:只注入相似度最高的 1 个资产。

测试 166 个,在 Node 22.22 和 Node 26 下都通过。之前 Node 22 下失败的那组 recall-judge 测试已随复核一起删除。

已知数据(需在线验证)

分层评估第 2 层离线回放,Hub 为 #3832,Jev 门槛 0.4,只测改写、不含复核:

题型 查询 召回@1 注入对口 注入误导
非模板题 前 400 字 29% 15% 24%
非模板题 改写 37% 19% 27%
金融模板题 前 400 字 65% 65% 10%
金融模板题 改写 30% 30% 65%

只改写、不复核时,非模板题小幅变好,金融模板题明显变差。合并前需要跑同一时段的小规模在线对照(main 对比本 PR),看完成率、token 和首步延迟。

成本与延迟

  • 每轮召回多 1 次模型调用,记在用户自己选的 provider 上,输入不超过 6000 字。
  • 改写在召回之前串行执行。推理模型可能要几秒,加上召回后可能超过 6 秒的首步等待,此时注入落到后续步骤。

回滚

git revert。

🤖 Generated with Claude Code

forrestlinfeng and others added 3 commits October 21, 2026 13:21
With EVOMAP_API_KEY set, recall asks gemini-3.5-flash on the EvoMap gateway to
rewrite the whole task (up to 6000 characters) into one English search query,
fetches the Hub's top ten for it, and has the same model judge each candidate
against the task (up to 4000 characters), one request per candidate sent
together. Up to five accepted candidates are injected; none are injected when
none is accepted. A failed rewrite searches with the 400-character prompt
prefix, a failed review injects the best candidate unreviewed, and both are
reported in the recall outcome and logged. Without the key recall is unchanged.

Offline over the 499-task bank this cut misleading injections from 715 to 13
while keeping 384 of 406 fitting ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A follow-up such as "Continue with the task from where you stopped." says
nothing about the work. Judged alone, its rewrite became a query about resuming
interrupted workflows and the review accepted three checkpointing playbooks for
a legal drafting task. The rewrite and the review now read the session's
opening prompt followed by this turn's; a fallback still searches with this
turn's prompt prefix, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gateway caps concurrent requests per key and answers 429
concurrency_limit; a review sends ten at once beside the agent's own calls
on the same key, and a lost verdict counts as a rejection. A 429 or 5xx is
retried twice, after 1 s and 3 s or the Retry-After it names (at most 5 s);
any other refusal fails at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@evomap-aiqa-bot

evomap-aiqa-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Sentinel 已审核此变更,未发现已核验问题,但发现需要人工确认的风险。

GitHub CI 未通过。 此状态来自当前 CI gate,不是 Sentinel finding;请以最新 CI attempt 的日志为准。

另有 5 个需要人工确认的风险;黄色 advisory 不阻塞合并,建议开发 agent review advisory 评论并逐条确认。

开发 agent 查询详情: 调用 MCP 工具 sentinel_pr_review_context,传入 owner_repo="evomap/evolver-dsh-plugin"、pr_number=49、head_sha="a3cf6e022a75baf93616610726dbb28891ea015a",并按条目追加 finding_id 或 finding_key。

由 Sentinel 审核 · 目标提交 a3cf6e022a75

@evomap-aiqa-bot

Copy link
Copy Markdown

Sentinel 保留了 5 个尚未确认的审核候选。这些黄色条目不阻塞合并;红色 P0/P1 与其他独立硬门禁不受影响。 单一猜测、缺少变更行证据或纯 checklist 的候选会统一降为 P3。
开发 agent:请 review 以下 advisory,并逐条给出“已验证无风险 / 已修复 / 转为后续事项”的结论;不要只做整体确认。

  • [P2] 网关错误响应在重试或抛错前未消费响应体 — completion() 只在成功响应上调用 response.json();所有非成功分支都会直接重试或抛错,没有...(truncated) · src/recall-judge.js · advisory_7f5222b0a02854623eaa55f9
  • [P2] 多个资产共用组合策略文本,导致复用结果错误归因 — 多资产模式把所有策略合并成单个 text,随后为每个资产分别调用 rememberInjected(..., { strate...(truncated) · src/prime.js·advisory_2d8d149a634666567f3a4d6d`
  • [P3] 延迟完成的旧回忆可能注入到后续任务 — hubMessages 超时后把未完成的 search 放到后台;完成回调只检查 signal?.aborted,没有检查原...(truncated) · src/index.js · advisory_08bbc79daccda5273472e419
  • [P3] 满长度后续提示会被无条件截掉末尾字符 — 当 prompt.length >= maxChars - 1 时,opening 被切为空字符串,但函数仍在当前提示前加入 \n\n,...(truncated) · src/prime.js · advisory_7209101a73b25939352b8ab3
  • [P3] 判定器绕过配置的 Proxy 直接向外部网关发送任务内容 — 现有召回请求通过 createProxyClient({ port: config.proxyPort, ... }) 进入本地 Proxy,但新增判定器使...(truncated) · src/recall-judge.js · advisory_26b3800e778712d3c1c01bb8

需要完整证据时,可用行末 finding_key 查询 Sentinel PR review context。

由 Sentinel 审核 · 目标提交 a3cf6e022a75

The query rewrite no longer calls a hard-coded gateway and model: it runs
on the provider and model the session already uses, through dsh's llm
service, so it needs no key of its own. Without that route, or when the
rewrite fails, recall searches with the prompt prefix as before.

The pre-injection review is gone, with the ten-candidate request, the
five-asset injection and the gateway retries: recall injects the single
best asset again, as on main. The review added up to ten model calls and
about ten seconds before the first step, and up to five strategies to
the context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@forrestlinfeng forrestlinfeng changed the title 召回前改写查询,注入前用完整题目复核候选 召回前用会话自己的模型改写查询 Oct 23, 2026
@evomap-aiqa-bot

evomap-aiqa-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Sentinel 已审核此变更,未发现已核验问题,但发现需要人工确认的风险。

另有 3 个需要人工确认的风险;黄色 advisory 不阻塞合并,建议开发 agent review advisory 评论并逐条确认。

开发 agent 查询详情: 调用 MCP 工具 sentinel_pr_review_context,传入 owner_repo="evomap/evolver-dsh-plugin"、pr_number=49、head_sha="05b06a2b37568cd2f4ae2fb43b660d31a4b204dc",并按条目追加 finding_id 或 finding_key。

由 Sentinel 审核 · 目标提交 05b06a2b3756

@evomap-aiqa-bot

Copy link
Copy Markdown

Sentinel 保留了 3 个尚未确认的审核候选。这些黄色条目不阻塞合并;红色 P0/P1 与其他独立硬门禁不受影响。 单一猜测、缺少变更行证据或纯 checklist 的候选会统一降为 P3。
开发 agent:请 review 以下 advisory,并逐条给出“已验证无风险 / 已修复 / 转为后续事项”的结论;不要只做整体确认。

  • [P2] 查询改写错误可能将凭据或任务内容写入日志 — chunk.reason.failure.message 来自外部 Provider/SDK;该字符串经 Error、rewrite_error 原样传播,未�...(truncated) · src/index.js · advisory_ee19d164d58abbff4e5f5a11
  • [P3] 满长度后续提示会丢失末尾字符 — 当本轮提示长度达到 maxChars - 1 或更长时,opening 已无可用空间,但函数仍在提示前添加 \...(truncated) · src/prime.js·advisory_01a60d01c346a584efb71fca`
  • [P3] 流提前结束时将部分文本误判为完整改写 — answerOf 只在收到带 reason.failure 的 finish 帧时失败,却不要求流必须出现成功 finish 帧��...(truncated) · src/recall-query.js · advisory_de940ae1019d754a154070e0

需要完整证据时,可用行末 finding_key 查询 Sentinel PR review context。

由 Sentinel 审核 · 目标提交 05b06a2b3756

forrestlinfeng and others added 2 commits October 23, 2026 17:17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@evomap-aiqa-bot

evomap-aiqa-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Sentinel 已审核此变更,未发现已核验问题,但发现需要人工确认的风险。

另有 6 个需要人工确认的风险;黄色 advisory 不阻塞合并,建议开发 agent review advisory 评论并逐条确认。

开发 agent 查询详情: 调用 MCP 工具 sentinel_pr_review_context,传入 owner_repo="evomap/evolver-dsh-plugin"、pr_number=49、head_sha="ce51ef3d9a59e9d874720a41c19b22ae5ee81b61",并按条目追加 finding_id 或 finding_key。

由 Sentinel 审核 · 目标提交 ce51ef3d9a59

@evomap-aiqa-bot

Copy link
Copy Markdown

Sentinel 保留了 6 个尚未确认的审核候选。这些黄色条目不阻塞合并;红色 P0/P1 与其他独立硬门禁不受影响。 单一猜测、缺少变更行证据或纯 checklist 的候选会统一降为 P3。
开发 agent:请 review 以下 advisory,并逐条给出“已验证无风险 / 已修复 / 转为后续事项”的结论;不要只做整体确认。

  • [P2] Provider 错误未经脱敏写入诊断和运行日志 — 外部 Provider/SDK 的 chunk.reason.failure.message 被原样包装为 Error,随后转成 rewrite_error;该��...(truncated) · src/index.js · advisory_afdba9b7cd29503906225a0a
  • [P2] 短 follow-up 在改写前被跳过 — taskOf 已将 opening 与当前提示组合成可供改写的完整任务,但 hubGene 仍仅按当前 promptText...(truncated) · src/prime.js · advisory_7874c1560e3b2affe04fd0ba
  • [P3] 满长度 follow-up 会丢失末尾两个字符 — 当当前提示已经占满 maxChars 时,opening 被截为空,但函数仍前置 \n\n,最后的 .slice(0, max...(truncated) · src/prime.js·advisory_6a808be3aeef00ea71804f00`
  • [P3] 满长度后续提示会被截掉末尾字符 — 当当前提示长度为 5999 或 6000 时,opening 已没有可用空间,但函数仍在提示前加入 \n\n,随...(truncated) · src/prime.js · advisory_43a0b6060b563e198942d820
  • [P3] 缺少 finish 帧时会把部分响应当作完整查询 — answerOf 只处理带 reason.failure 的 finish 帧,但不记录是否收到成功 finish。如果 Provider ��...(truncated) · src/recall-query.js · advisory_9de155cd3f25d4ad6753db7f
  • [P3] 超时后的旧召回可能写入后续 turn — 本 PR 在召回前增加最长 12 秒的 LLM 改写,使搜索更容易越过 inline 等待预算。后台完成回调...(truncated) · src/index.js · advisory_55a193f0ce9e6a2a83d60c43

需要完整证据时,可用行末 finding_key 查询 Sentinel PR review context。

由 Sentinel 审核 · 目标提交 ce51ef3d9a59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant