Skip to content

[codex] 修复 PKM 澄清请求后的循环重试#153

Merged
utopiafar merged 1 commit into
memex-lab:mainfrom
utopiafar:codex/pkm-clarification-loop-completion
May 18, 2026
Merged

[codex] 修复 PKM 澄清请求后的循环重试#153
utopiafar merged 1 commit into
memex-lab:mainfrom
utopiafar:codex/pkm-clarification-loop-completion

Conversation

@utopiafar
Copy link
Copy Markdown
Collaborator

背景

Closes #146

这个 issue 是合理的:当前 PKM workflow 的完成证据只接受“P.A.R.A. 写入 + card insight”或显式 skip;但真实 replay 里的信息不足场景已经创建了 clarification request,却仍被视为未完成,后续 retry 会反复走相同的空搜索、重复澄清或重复读取,最终触发 loopDetection / max turns。

改动

  • create_clarification_request 返回明确的去重状态:request_idcreated=true/falsededupe_key,让 agent 能识别“已存在同 key 请求”并停止重复创建。
  • 将“成功创建或命中 clarification request,且没有发生 PKM 文件 mutation”纳入 PKM completion evidence。
  • AgentExceptionCode.loopDetection 发生时,如果历史里已经存在有效 completion evidence,PKM task 会按完成处理,避免 LocalTaskExecutor 继续重试同一死路。
  • 调整 PKM prompt:信息不足时使用一次 ask_clarification 收口;同参空 Glob / Grep、重复 Read 不应继续打转。
  • 补充单测覆盖 clarification completion path、mutation 后不能只靠 clarification 完成,以及 clarification dedupe 返回状态。

验证

  • env -u ws_proxy -u wss_proxy no_proxy=localhost,127.0.0.1,::1 flutter pub get --offline
  • env -u ws_proxy -u wss_proxy no_proxy=localhost,127.0.0.1,::1 dart analyze lib/agent/pkm_agent/pkm_agent.dart lib/agent/prompts.dart lib/agent/skills/ask_clarification/ask_clarification_skill.dart lib/data/services/clarification_request_service.dart test/agent/agent_tool_error_result_test.dart test/agent/pkm_agent_skip_completion_test.dart
  • env -u ws_proxy -u wss_proxy no_proxy=localhost,127.0.0.1,::1 flutter test --no-pub test/agent/pkm_agent_skip_completion_test.dart test/agent/agent_tool_error_result_test.dart

备注:flutter analyze --no-pub 可执行,但当前 main 基线已有 324 个 info 级 lint,因此本 PR 用触达文件的 dart analyze 作为静态检查 gate。

@utopiafar utopiafar force-pushed the codex/pkm-clarification-loop-completion branch from da2846b to 2d77d42 Compare May 18, 2026 17:12
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

PR Preflight Summary / PR 预检汇总

中文

  • 统一结论:低风险:两个预检均已完成,质量预检通过,可走普通手动合并流程。
  • Policy preflight:低风险。未命中打回、高风险或警告规则。
  • Flutter quality:通过。Analyzer 和 test baseline 均未发现新增问题。
  • PR head:2d77d42269bd2f24ccc87619bbf9e2dc981c3dfd
  • Policy run:26049151498
  • Flutter run:26049151572

English

  • Combined result: Low risk: both preflights completed and quality passed; use the normal manual merge flow.
  • Policy preflight: LOW RISK. No blocking, high-risk, or warning policy signal was found.
  • Flutter quality: PASS. Analyzer and test baselines found no newly introduced issue.
  • PR head: 2d77d42269bd2f24ccc87619bbf9e2dc981c3dfd
  • Policy run: 26049151498
  • Flutter run: 26049151572
PR Policy Preflight / PR 规则预检

PR Policy Preflight / PR 规则预检

中文

  • 判定:低风险
  • 变更文件数:0
  • 变更行数:0
  • Diff 是否截断:false

未发现确定性规则问题。

English

  • Decision: LOW RISK
  • Changed files: 0
  • Changed lines: 0
  • Diff truncated: false

No deterministic policy findings.

PR Flutter Quality / Flutter 质量预检

PR Flutter Quality / Flutter 质量预检

中文

  • 总体:通过
  • Analyzer baseline:通过
  • Test baseline:通过

English

  • Overall: PASS
  • Analyzer baseline: PASS
  • Test baseline: PASS

Flutter Analyzer Baseline

  • Base issues: 324
  • PR issues: 324
  • New issues: 0

No new analyzer issues introduced by this PR.

Flutter Test Baseline

  • Base failures: 11
  • PR failures: 11
  • New failures: 0

No new Flutter test failures introduced by this PR.

@utopiafar utopiafar marked this pull request as ready for review May 18, 2026 17:22
@utopiafar utopiafar merged commit bb4b9e5 into memex-lab:main May 18, 2026
4 checks passed
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.

PKM agent 对信息不足/搜索无结果场景反复工具调用,导致真实 replay 未收敛

1 participant