Skip to content

chore(agent-core-v2): slim tool and subagent prompts - #4483

Closed
7Sageer wants to merge 5 commits into
chore/slim-tool-prompts-followupfrom
chore/slim-agent-prompts
Closed

7Sageer wants to merge 5 commits into
chore/slim-tool-prompts-followupfrom
chore/slim-agent-prompts

Conversation

@7Sageer

@7Sageer 7Sageer commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

在 #4476 之上继续精简工具描述与 subagent prompt,删掉已由 schema 或其他描述承接的重复文本,降低每次请求的固定开销。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

Stacked on #4476。Goal / Plan 提醒的 full / sparse 改动已拆到后续 PR #4518。

  • 14 个工具描述合计减少 3,157 字符,精简参数 schema、其他工具描述或实际返回值已承接的重复文本,并取消 Edit 前的强制 Read 要求。
  • system prompt 拆成可组合的片段,只读 profile(Explore / Plan)不再接收 Coding 和变更交付规则:
 app/agentProfileCatalog/
 ├── system.md                      # 骨架,引用下面的片段
+├── coding.md                      # 只读 profile 不注入
+├── delivering-work.md             # 主 agent / coder / Tower worker
+├── delivering-work-read-only.md   # Explore / Plan
+└── project-information.md         # 空 AGENTS.md 时只读 profile 省略;只读 profile 不含“修改后同步 AGENTS.md”一句
  • 主 agent 的 Plan 模式指引保留,并从约 390 字符压缩到 268:只有用户能开启 Plan 模式(模型不能自己进入);被要求开启时告诉用户怎么开;用户要求先规划时,等确认后再改代码。注入条件不变(ExitPlanMode 可用时注入)。
  • system prompt 中的 NOTIFY_USER_GUIDANCE 从 870 字符压到 244,只保留“主动使用、何时发”的提醒;格式、subagent 与 parent 可见性规则均在 NotifyUser 工具描述中。
  • subagent 身份前缀压缩;Explore / Plan 角色文本去重。

以同一份 AGENTS.md 内容渲染时,system prompt 字符变化:

Profile 改前 改后 减少
主 agent 9,295 8,327 968
coder / Tower worker 9,763 8,635 1,128
Explore 10,607 5,730 4,877
Plan 10,018 5,063 4,955

Behavior Changes and Affected Users

受影响人群:所有接收内置工具描述的会话(TUI、print 模式、desktop 与 web、VS Code、ACP、SDK),以及实际使用内置 coder、Explore、Plan 与 Tower worker 的会话。自定义 profile 未设置 readOnly 时不会进入只读模板;AGENTS.md 内容在所有 profile 中仍完整注入。

Behavior Before After Who relies on the old behavior Escape hatch
Agent 授权段 用较长段落列授权来源、反例、agent type 与 resume 规则 同一段压缩表达相同规则 使用 Agent 的主 agent 完整授权规则仍在 Agent 描述
Agent lookup 指引 另用一句说明不要让 subagent 搜索已知信息 合并为一句 委派 lookup 的主 agent 已知路径/命令与“不要委派理解”仍在
Edit 的 Read 视图句 正文要求 old/new 来自 Read output view 删除重复句 所有使用 Edit 的会话 old_string / new_string schema;行号与 tab 规则仍保留
Edit 前的强制 Read 每次 Edit 前都必须 Read,且禁止根据已有上下文编辑 不再强制每次前置 Read;同文件连续 Edit 之间仍要求重读 依赖提示词强制刷新文件内容的会话 Read 视图 schema 与同文件重读规则仍保留;没有恢复强制前置 Read 的开关,本次删除已经维护者确认
Edit 的 replace_all 示例句 正文重复所有匹配才启用的规则 删除重复句 所有使用 Edit 的会话 replace_all schema
Edit 的 write-lock 句 说明同文件写入串行化 删除实现细节 连续编辑同一文件的会话 同文件重读和禁止连续陈旧编辑的规则仍在
Glob 的 ignore / sensitive-file 段 正文展开忽略文件和敏感文件规则 删除重复段 所有使用 Glob 的会话 include_ignored schema
Glob 的非快照分页句 正文说明重新搜索和分页漂移 删除重复句 分页使用 Glob 的会话 offset schema
Grep 的 ignore / sensitive-file 段 正文展开规则并给示例 仅保留默认搜索 hidden files 所有使用 Grep 的会话 include_ignored schema
Read 的 Grep 路由句 在 Read 中再次说明何时用 Grep 删除重复句 在 Read/Grep 间选择的会话 Grep 描述与 path schema
Write 的增量编辑与完整替换两条 两条分别禁止增量编辑和限定使用场景 合并为一条,规则不变 所有使用 Write/Edit 的会话 合并后的正文仍明确使用 Edit
Write 的行号前缀禁令 正文禁止携带行号前缀 不变(保留) — —
ReadMediaFile 的附件来源句 正文说明当前会话附件引用 删除重复句 读取会话附件的会话 path schema;服务端路径与转换器约束仍在
ReadMediaFile 的 Read/Glob 路由 正文再次列出文本读取和文件查找工具 删除重复句,保留大小上限 读取媒体与文本的会话 path schema 限制图片/视频及不支持的文本
TaskList 的默认 non-terminal 句 正文重复默认过滤规则 删除重复句 查询后台任务的会话 active_only schema 的 default(true)
TaskOutput 的返回结构与 output_path 段 正文预告 metadata、preview 和完整日志读法 删除重复段 读取后台任务输出的会话 实际返回的 formatTaskRecord 与 fullOutputHint
CronCreate 的 7 天有效期 正文重复 recurring 任务有效期 删除重复分句 创建 recurring cron 的主 agent recurring schema;stale 处理仍在
WaitFor 的 timeout 句 正文重复必填、上限 90 秒、按预期时长选取 删除 启用 WaitFor flag 的会话 timeout schema 含相同三点
WaitFor 的超时句 正文说明超时不是错误、结果列出仍在运行的任务 只保留“超时后优先做其他工作、不要反复等待” 启用 WaitFor flag 的会话 timeout schema 说明超时不是错误及返回内容
WaitFor 的无 task_id 句 正文说明任一任务结束即返回 只保留“等待期间新启动的任务不覆盖” 启用 WaitFor flag 的会话 task_id schema
WaitFor 的返回分组句 预告结果会列出窗口内其他已完成任务 删除 启用 WaitFor flag 的会话 实际返回的分组
AskUserQuestion 的 Other / multi_select / 标签长度 / 选项数 / 问题数 / (Recommended) 后缀 正文逐条重复 删除;保留唯一性约束、成组提问、推荐项放首位 所有使用 AskUserQuestion 的会话 options、multi_select、label、description、questions schema
NotifyUser 的 title / message 格式 正文重复单行、语言、长度、纯文本、轻 Markdown 等要求 保留 schema 未覆盖的部分:title 无 Markdown 与句号;message 的段落结构、避免表格与宽代码块、自包含、不复述状态 使用 NotifyUser 的会话 title / message schema
TodoList 的“只在完全完成时标 done” 与 “Never mark done if…” 两句重复 删除前者 使用 TodoList 的会话 “Never mark a task done if tests are failing…” 仍在
system prompt 的 NotifyUser 段 870 字符复述何时发、格式、subagent 范围、parent 不可见、不是最终答复 只保留主动使用与何时发 NotifyUser 启用的主 agent 与 subagent;自定义 profile 也追加该段 格式、subagent 范围与 parent 不可见规则在 NotifyUser 描述;“最终答复自包含”在 system prompt 沟通段
主 agent 的 Plan 模式指引 三句:只有用户可开启、告知开启方法、先规划时等确认 压缩为同样三条约束 ExitPlanMode 可用的主 agent 语义不变;注入条件不变
共享模板的专用工具理由句 解释权限 UI 和输出截断收益 删除理由,保留专用工具优先规则 所有主 agent 与内置 subagent 专用工具映射及 Grep 的安全约束仍在
共享模板的 Agent 授权句 在 system prompt 与 Agent 描述中重复授权 仅保留 Agent 描述中的完整规则 可使用 Agent 的调用方 agent.md 的完整授权段
subagent 身份前缀 用五句说明 caller、可见性与歧义处理 压缩为两句,规则不变 coder、Explore、Plan、Tower worker 前缀及 coder handoff 仍保留
coder / Tower handoff 重复句 再次说明 parent 只能看到最终消息 删除重复说明 coder 与 Tower worker subagent 身份前缀
Explore strengths 列出搜索、读取和只读 shell 能力 删除能力宣传 Explore subagent 角色说明与实际工具清单
Explore 的 Grep/Read 路由 重复工具选择指引 删除重复指引 Explore subagent Grep/Read 工具描述
Explore 的并行提示 单独要求并行 grep/read 删除重复句 Explore subagent 共享模板的独立调用并行规则与 Read 描述
Explore 的 Bash 只读两条 两条分别限定只读和禁止修改 合并为一条,约束不变 Explore subagent 合并后的 Bash 只读规则
Plan 的上下文判断与输出契约 用较长文本说明 explore 升级和三项输出 压缩文本,保留三项输出 Plan subagent 与接收计划的调用方 仍返回已知、待 explore 问题、初步或最终计划
Plan 的只读与工具说明 重复 shell、编辑和 web 能力 压缩为只读禁令及最终交付 Plan subagent 工具清单及“禁止命令或修改”的正文
Explore / Plan 的 Coding 与变更验收段 接收编码、测试、变更验收和清理规则 替换为精简只读交付规则 依赖这些通用规则的只读 subagent 只读角色与精简 Delivering work;Risky actions 与 Context management 仍保留(subagent 同样会 compaction)
Explore / Plan 的“修改后同步 AGENTS.md”句 只读 profile 也收到 只读 profile 省略这一句;其余 Project information 不变 只读 subagent(不修改文件) 主 agent / coder 仍保留
空 AGENTS.md 的 Project information 所有 profile 都显示通用说明和空代码块 仅只读 profile 省略该段 无 AGENTS.md 工作区中的只读 subagent 空内容无需读取;主 agent/coder 保留原段
Prompt cache 工具与 system prompt 文本沿用上一版本 升级后的新请求重新计算 prompt 前缀 所有客户端的已有会话 一次性 cache miss,后续恢复正常

参数 schema、配置键、环境变量、wire / state 契约、kap-server API、工具执行逻辑和 Tower 工具清单均未修改。未接入生产路径的 human 层描述(src/human/tool/wait-for.md、src/human/todo/todo-list.md)未改动。文档无需更新:没有新增或变更用户命令、配置或操作方式。

测试与覆盖:

范围 覆盖
默认 profile 与动态段落 profile-shared.test.ts:只读 profile 的 Coding / Delivering work 切换、空 Project information 省略、AGENTS.md 维护句只对可写 profile 保留;Plan 模式指引的位置、注入条件、只读 profile 不注入;NotifyUser 段保留主动提醒,subagent 与 parent 规则改为断言工具描述
Plan 模式可用性探测 apply-profile.test.ts:ExitPlanMode 可用时才标记 planModeAvailable
coder / Explore / Plan profiles.test.ts:完整 coder 规则、只读 profile、AGENTS.md 保留、Explore 前缀只出现一次
Tower worker workerProfile.test.ts 覆盖工具清单与 plan mode 工具边界
工具描述 read.test.ts、task / notify / todo 工具测试
定向回归 相关 38 个测试文件共 1,281 条通过;agent-core-v2 typecheck、check-no-comments、oxlint 0 errors

已知 base 问题:Agent tool execution contract > returns the spawned agent id when a foreground subagent times out 在 #4476 已记录为 base 的 30 秒超时;本 PR 未修改该执行路径。

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.

@changeset-bot

changeset-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 941155d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-29T10:41:33.229920Z 941155d Manual request
ℹ️ 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.

@7Hanrui

7Hanrui commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@codex review

@pkg-pr-new

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

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

commit: 941155d

@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: 7599fa9da5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +908 to +909
agentsMd: profile.omitAgentsMd === true ? '' : base.agentsMd,
agentsMdPaths: profile.omitAgentsMd === true ? [] : base.agentsMdPaths,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve AGENTS.md for read-only agents

When an Explore or Plan run can answer from context supplied by its caller without making a filesystem tool call, these lines remove both the applicable instructions and their paths before the first model request; no discovery reminder can then fire, so repository-specific planning or review requirements are silently ignored even though they were always injected before this change. The generic instruction to read AGENTS.md “when relevant” cannot identify unknown scoped rules, and there is no config or flag to restore the previous behavior, so retain injection or guarantee that applicable instructions are loaded before these profiles start.

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

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

已按建议处理:Explore 和 Plan 恢复完整 AGENTS.md 自动注入,omitAgentsMd 及相关清空逻辑已移除,paths、reminder 和 change-notifier beliefs 均与 base 一致;只读模板与其他 prompt 精简保留。最终提交 9c0e6f6,AgentGym 全量测试 17,930 passed、31 skipped、0 failed。

@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: 9c0e6f696e

ℹ️ 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".

Comment on lines +180 to +182
agentsMd.length > 0 || options.readOnly !== true
? renderPrompt(PROJECT_INFORMATION_SECTION, { agents_md: agentsMd })
: '',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep nested AGENTS discovery guidance in read-only prompts

When an Explore or Plan agent starts in a workspace with no applicable AGENTS.md but inspects a subdirectory that has one, this condition drops the entire Project information section, including its instruction to check subdirectories; neither read-only role replaces that guidance, so the agent can silently miss rules governing the files it analyzes. Preserve the discovery instruction while omitting only the empty content block.

AGENTS.md reference: AGENTS.md:L119-L121

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@codex review

@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: 9c0e6f696e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

"@moonshot-ai/kimi-code": patch
---

Shorten built-in tool and subagent prompts.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Name the read-only guidance that users lose

For users of the built-in Explore and Plan agents, this commit removes the coding, end-to-end verification, blocked-work, and test-cleanup guidance without an escape hatch, but the release entry describes only a generic prompt shortening. Releases generated from this changeset will therefore hide the user-perceivable behavior loss; name the removed guidance and state that the old behavior is no longer available.

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

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 1384c2f580

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@7Hanrui

7Hanrui commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 9502baea8b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@7Sageer
7Sageer force-pushed the chore/slim-agent-prompts branch from 9502bae to 1cd9fcb Compare October 29, 2026 09:55
@7Hanrui

7Hanrui commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 1cd9fcbbaa

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@7Hanrui

7Hanrui commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 941155d4e1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@7Sageer

7Sageer commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

已由统一 PR #4521 收拢,目标分支为 release/2026-10-29;保留原分支与历史,不再单独合并此 PR。

@7Sageer 7Sageer closed this Oct 29, 2026
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.

2 participants