Skip to content

fix(agent-core-v2): answer questions without edits and clean up test leftovers - #4450

Merged
RealKai42 merged 4 commits into
mainfrom
fix/request-type-deliverable
Oct 27, 2026
Merged

RealKai42 merged 4 commits into
mainfrom
fix/request-type-deliverable

Conversation

@RealKai42

@RealKai42 RealKai42 commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

提问、讨论和诊断类请求不改文件;跑测试或构建留下的日志,在回复前清理掉。

Bug Reproduction Steps

在两个小型 Node 项目里用 kimi -p 复现。基线是当前 main 的系统提示,所有运行使用同一个 Kimi 模型。

  1. 项目的 tests/run.js 每次运行都会写 tests/recparse.log 和 tests/recparse.trs。提问「现在的测试用例覆盖了只有空格的行吗?当前测试实际跑出来是什么结果?」。agent 跑了 npm test 并正确作答,但结束后 git status 仍显示这两个未跟踪文件(3/3)。
  2. 配置加载代码读取的字段名和 notify.yaml 里的不一致,npm run send 返回 401 missing_token。提问「npm run send 报 401 missing_token,帮我看一下。」。agent 直接改了加载代码(3/3)。

Root Cause

system.md 的 Delivering work 开头只有一句 "Do what was asked",没有区分提问、诊断和行动请求,要不要改文件全由模型自行判断。验证段要求跑标准构建和测试,但没有任何指令处理这些命令在项目里留下的文件,模型也不会主动去看。

本 PR 在提示词层补上这两条约束,针对的是根因,不是绕过。但它们是软约束:模型仍可能偶尔不照做(评测里清理仍有少量遗漏),引擎层没有对应的保证机制。

Code Changes

只改了 packages/agent-core-v2/src/app/agentProfileCatalog/system.md 的 Delivering work 节两处,原有句子一字未删,新内容都是在原句后追加:

-Do what was asked. Goals the user states explicitly count as part of the ask.
+Do what was asked. Goals the user states explicitly count as part of the ask, and the kind of request sets the deliverable. A request for action, including one phrased as a question such as "can you add…", gets the work done, carried through. A question or an explanation gets an answer backed by what you found, and a discussion of how to approach something gets your recommendation and its main tradeoff first; either way, leave the project as you found it unless the user also asks for a change. When asked why something fails, find the cause before you name it. A familiar error can have a different cause. Say what you confirmed and what is still a hypothesis, and fix it only if the user asked for a fix.
-${todo_list_guidance}Before you finalize a reply, re-read the user's latest request and confirm you are answering that one — check every explicit requirement: formats, threshold directions, and each "must".
+${todo_list_guidance}Before you finalize a reply, re-read the user's latest request and confirm you are answering that one — check every explicit requirement: formats, threshold directions, and each "must". After you run tests or builds in the project, check for new files before you reply (`git status` in a repository) and delete the ones your runs created that the task does not need, such as logs and test output; report what you need from them in your reply instead. Leave files you did not create alone; if you cannot tell whether your run created a file, keep it and say so.

新增句的含义与依据:

新增句 含义 依据
the kind of request sets the deliverable 请求类型决定交付物 Codex gpt-5.6 系列模型指令(codex-rs/models-manager/models.json):"Adapt accordingly based on the user's request type"
A request for action, including … "can you add…", gets the work done, carried through 行动请求(包括问句式的)要做完,防止变被动 Codex gpt-6.1 模型指令:"When the user's prompt indicates a request for action, such as "can you..." … treat these as instructions to do the work and take action"
A question or an explanation gets an answer backed by what you found 提问和解释,交付有证据支撑的回答 Codex gpt-5.6:"Answer, explain, review, or report status: inspect the task and provide an evidence-backed response"
a discussion of how to approach something gets your recommendation and its main tradeoff first 讨论怎么做时,先给建议和主要取舍 业界 coding agent 对探索式问题的同类规则(先给建议和主要取舍,用户同意前不动手)。原规则还限定回答长度,这里不采用,长度由本仓的回复风格指引控制
either way, leave the project as you found it unless the user also asks for a change 两种情况都保持项目原样,除非用户同时要求修改 Codex gpt-5.6:"These user requests do not authorize … mutations unless the user also asks for a change. Reversible, non-mutating diagnostic checks are allowed when they are relevant"
When asked why something fails, find the cause before you name it 诊断先找到原因再下结论 Codex gpt-5.6:"Diagnose: determine the cause and explain it"
A familiar error can have a different cause 眼熟的错误可能另有原因 业界 coding agent 自主运行指令中的同类规则(原规则用于执行改变系统状态的命令之前)
Say what you confirmed and what is still a hypothesis 区分已确认的事实和推测 与本仓 NotifyUser 工具说明中已有的同类要求一致
fix it only if the user asked for a fix 只有用户要求才修 Codex gpt-5.6:"Do not implement the fix unless the user asks for a fix or the request otherwise clearly includes implementation"。后半句没有采用,原因见下
After you run tests or builds … check for new files before you reply (git status in a repository) 跑完测试或构建,回复前检查有没有新文件 没有直接出处,根据评测加入:只写"可以清理"时 0/5 清理,加上检查动作后,测试结果提问各轮的清理率在 8/10 到 5/5 之间
delete the ones your runs created that the task does not need … report what you need from them in your reply instead 删掉自己的运行产生、任务又不需要的文件,需要的信息写进回复 业界 coding agent 执行安全指令中的同类规则(本会话自己产生的临时产物可以自行清理)
Leave files you did not create alone; if you cannot tell whether your run created a file, keep it and say so 不动不是自己创建的文件;分不清是不是自己产生的,就保留并在回复里说明 Codex gpt-5.6:"Existing or new changes belong to the user unless you know otherwise, so you preserve them";同上业界规则(不确定用户是否要保留时,优先可逆处理而不是删除)。这里选择原地保留,不挪动文件

没有采用 Codex 诊断规则的后半句 "or the request otherwise clearly includes implementation"。加上它之后,「帮我看一下」5 次里有 2 次直接改了代码,两次的推理都引用了这半句作为动手的理由。不加它,「…我今天要用它发通知,帮我处理一下」这类明显要处理的请求仍然 3/3 修好,因为这类请求本身就是行动请求。

第一句用 "action" 而不是 "change":换成 "A request for a change" 的对照版本,「帮我看一下」6 次里有 2 次改了代码,推理引用了这句;"action" 版本 10 次里 0 次。样本小,但没有证据说明 "action" 更容易让模型动手。

packages/agent-core-v2/test/app/agentProfileCatalog/profile-shared.test.ts:plan 指引位置的断言原来锚定旧句尾 count as part of the ask.,改为锚定新句尾,断言意图不变。

不附 changeset:这次只调整默认系统提示的行为细节,不作为面向用户的变更记录。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
问句式的行动请求(「你能加…吗」「你能跑一下测试吗」) 无明确约束 视为行动请求并做完 无 无需
提问、解释时是否改项目 无明确约束,由模型自行判断 交付有证据支撑的回答,不改项目,除非用户同时要求修改 问「这里算不算 bug」一类问题、期望 agent 顺手改掉的 TUI 与 print 模式用户 明确要求修改,如「改一下」
讨论方案时怎么回答、是否改项目 无明确约束 先给建议和主要取舍,不改项目,除非用户同时要求修改 用「你觉得这里怎么改」一类说法、期望 agent 直接动手的用户 明确要求修改,如「实现它」
诊断类请求(「为什么失败」「帮我看一下」) 常直接修改代码(实测「帮我看一下」3/3 直接修改) 定位原因并给出修法,不改文件,除非用户要求修复 说「帮我看一下」就期望直接修好的用户;在 print 模式脚本里用诊断语气提需求的调用方 明确要求修复或处理,如「修一下」「帮我处理一下」
诊断时是否实际复现报错 偶尔 更常运行一次失败的命令来确认 对请求数敏感的 print 模式用户 无
跑完测试或构建后留在项目里的新文件 留在项目里(实测 3/3) 回复前检查新文件,删掉自己的运行产生、任务不需要的日志和测试输出;分不清是不是自己产生的,保留并在回复里说明;不动不是 agent 创建的文件 希望保留测试日志自行查看的用户 要求 agent 保留这些文件
跑过测试或构建的任务的工具调用数 — 多一次 git status,以及可能的删除操作 对请求数敏感的 print 模式用户 无

受影响人群:所有使用内置系统提示模板的 agent,包括默认主 agent、coder、explore、plan 子 agent 和 Tower worker;覆盖 TUI、print 模式(kimi -p)、desktop 与 web、ACP、SDK 等入口。不受影响的有两类:用 SYSTEM.md 或 agent 文件整体替换系统提示、且没有使用 ${base_prompt} 的用户;恢复的旧会话,它们沿用当时记录的系统提示,只有新会话才生效。

需要维护者拍板:「帮我看一下」这类请求不再默认修复。没有配置开关,退路是明确要求修复。请确认接受这一行为变化。

测试覆盖

  • 结构:系统提示模板、agent 配置加载和 plan 相关的 21 个测试文件、434 个测试通过。
  • 行为:在仓库外做了 A/B。各组用同一个 kimi 2.3.2 二进制和同一个 Kimi 模型,都在 kimi -p(auto 模式)下运行,只有系统提示不同:通过 --agent-file 加载,每次运行都从会话日志核对实际发出的提示。场景都是自建的小型 Node 项目。
场景 基线 最终文本
诊断「为什么失败」(字段为空、读错配置文件、字段名不一致、本地配置用空值覆盖默认值):找对原因 / 未改文件 13/13 / 13/13 4/4 / 4/4
「报错了,帮我看一下」:未改文件 0/3 10/10(均给出原因和修法)
「报错了,我今天要用它发通知,帮我处理一下」:已修好 — 3/3
提问、讨论、解释:未改文件 18/18(6 类) 2/2
「你能跑一下测试吗?」:跑了测试 / 结束时工作区干净 3/3 / 0/3 2/2 / 1/2
会写日志的测试结果提问:结束时工作区干净 0/3 5/5
同上,且项目里有用户原有的未跟踪 debug.log:该文件被保留 / 其余文件已清理 3/3 / 0/3 3/3 / 3/3
修改类(问句式的分页请求):功能检查与 npm test 通过 3/3 2/2

另有一个只比最终文本多出上述 Codex 诊断后半句的版本(未采用),在更多场景上跑了 48 次,可作参考:提问、讨论、解释 12/12 未改文件;测试结果提问 8/10 干净;带 debug.log 的 5/5 保留、5/5 其余已清理;「你能跑一下测试吗?」3/3 跑了、3/3 干净;修改类(分页、日志级别、按项目配置目录新增布局文件、问句式分页)5/5 通过;诊断 8/8 找对原因且未改文件;「帮我看一下」3/5 未改文件。

清理没做到的几次,都是跑完测试后没有执行 git status 检查,不是因为"分不清就保留"而留下文件;用户原有文件在所有带新清理文本的运行里都被保留(8/8)。

成本:跑测试的提问每次多约 2 次请求(git status 与删除),输入 token 多 70%–95%,但几乎全是缓存命中,未命中的部分每次只多约 1k;诊断题、讨论题与基线相差在 1 次请求以内,修改类没有变多;「帮我看一下」因为不再动手修改,平均少约 2 次请求。每组 1–10 次,含噪声。

未覆盖:其他模型、交互式 TUI(非 auto 模式)、子 agent 与 Tower 的行为、非 git 项目、Windows。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

没有关联 issue。行为变化表已完整列出,但按上面的说明没有写 changeset;「帮我看一下」不再默认修复这一项的退路是明确要求修复,请维护者在本 PR 中确认。仓库内只更新了结构断言,行为效果由上面的 A/B 验证,没有加入仓库测试。用户文档没有描述默认提示词在提问和修复上的行为,所以不需要更新文档。

…leftovers

Let the request type decide the deliverable in Delivering work: change
requests (including "can you add..." questions) get the change, while
questions, explanations, and discussions get an answer that leaves the
project untouched. Diagnosis requests find the cause before naming it,
separate confirmed facts from hypotheses, and apply a fix only when asked.

Before replying after running tests or builds, check for new files and
delete the logs and test output those commands created when the task
does not need them, without touching files the agent did not create.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 15:43
@changeset-bot

changeset-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a510a1b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T06:26:12.611169Z a510a1b New commits
🔒 Security Review ✅ Completed 2026-10-26T15:48:34.361265Z d43430e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@a510a1b
npx https://pkg.pr.new/@moonshot-ai/kimi-code@a510a1b

commit: a510a1b

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cab20c1bb6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# Delivering work

Do what was asked. Goals the user states explicitly count as part of the ask.
Do what was asked. Goals the user states explicitly count as part of the ask, and the kind of request sets the deliverable. A request for action, including one phrased as a question such as "can you add…", gets the work done, carried through. A question or an explanation gets an answer backed by what you found, and a discussion of how to approach something gets your recommendation and its main tradeoff first; either way, leave the project as you found it unless the user also asks for a change. When asked why something fails, find the cause before you name it. A familiar error can have a different cause. Say what you confirmed and what is still a hypothesis, and fix it only if the user asked for a fix.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add a CLI changeset for the changed default behavior

For TUI and print-mode users who phrase a repair request as “help me look at this,” this changes the default from potentially applying a fix to diagnosis-only; it also changes whether generated test logs remain available afterward. The commit explicitly acknowledges these user-visible changes but excludes a changeset because they are system-prompt details. Root AGENTS.md requires a changeset naming lost behavior, and the changeset skill explicitly includes internal-package changes that affect CLI behavior. Add a changeset for @moonshot-ai/kimi-code describing the changed defaults and how users can explicitly request repairs or retain output files, so upgrading users can discover the change.

AGENTS.md reference: AGENTS.md:L117-L117

Useful? React with 👍 / 👎.

wbxl2000
wbxl2000 previously approved these changes Oct 27, 2026
…verable

# Conflicts:
#	packages/agent-core-v2/test/app/agentProfileCatalog/profile-shared.test.ts
@RealKai42
RealKai42 merged commit 39d149e into main Oct 27, 2026
16 checks passed
@RealKai42
RealKai42 deleted the fix/request-type-deliverable branch October 27, 2026 06:33
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
MoonshotAI#4410 MoonshotAI#4413 MoonshotAI#4431 MoonshotAI#4450 MoonshotAI#4451 MoonshotAI#4485 MoonshotAI#4524 were each implemented earlier —
the compaction prefix suite, the media-recovery case, the OAuth callback
socket drain, the split delivering-work section, the compaction wording,
the reasoning-key order and the 10-step todo reminder are all in the tree
and pinned by their own tests. Each row now carries that probe.

Only MoonshotAI#4410 needed care: upstream patched paths that this fork renamed
(`human/llm/builtin/protocol` versus `human/llm/requester/bases`), so the
matching was done on the behaviour — stripDynamicToolContext is gone and
extractEventUsage already reads usage only on terminal response events.

Ledger: closed 22 -> 28, remaining 71.
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.

3 participants