Skip to content

chore(agent-core-v2): trim remaining tool descriptions - #4476

Closed
7Sageer wants to merge 1 commit into
chore/slim-cron-tool-promptsfrom
chore/slim-tool-prompts-followup
Closed

7Sageer wants to merge 1 commit into
chore/slim-cron-tool-promptsfrom
chore/slim-tool-prompts-followup

Conversation

@7Sageer

@7Sageer 7Sageer commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

在 #4466 之上继续精简内置工具描述,减少每次请求中重复的固定 prompt 开销。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

Stacked on #4466;本 PR 只包含其最新 head 之后的一个提交。

按 Markdown 源文件字符数统计,12 个描述从 19,687 降到 11,353,合计减少 8,334 字符:

分组 工具 改前 改后 减少
已有描述去重 Read / Bash / Agent / CronCreate 6,053 5,614 439
媒体读取 ReadMediaFile 2,492 490 2,002
文件匹配 Glob 2,303 973 1,330
后台任务 TaskOutput / WaitFor / TaskList 5,355 1,451 3,904
文件工具去重 Grep / Write / Edit 3,484 2,825 659
合计 19,687 11,353 8,334

删减标准与 #4466 一致:

  1. 参数 schema 已经说明的默认值、取值范围和调用方式,不在正文重复。
  2. 工具状态块、返回字段和报错在实际发生时给出的指引,不在每次请求里预先展开。
  3. 跨段落重复的规则只留一处;保留调用前必须知道的约束,例如并行读取、生成媒体后回读、避免轮询、压缩后重新枚举任务 ID。
  4. 不改参数结构、工具执行逻辑、Plan 文案或 ExitPlanMode 的 options 规则。

测试无需同步:#4466 已将通用工具快照和 toolsHash 归一化,并移除 compaction 对内置 prompt 固定开销的断言。本 PR 只修改 12 个 Markdown 描述文件,不改测试。

Behavior Changes and Affected Users

受影响人群:所有主 agent 会话(TUI、print 模式、desktop 与 web、VS Code、ACP、SDK)。子 agent 按实际工具清单接收对应描述,包括 coder、explore、plan 和 Tower worker;Cron 只对主 agent 开放,Write / Edit 不进入只读 profile。下表中的“对应会话”均指实际接收该工具描述的主 agent 或子 agent。

Read / Bash / Agent / Cron / Grep / Write / Edit

句子 / 段落 改前约束了什么 现在由什么约束
Read 的目录处理句 不用 Read 读目录;已知目录用 ls,模式查找用 Glob ReadInputSchema.path 逐字保留相同规则
Bash 的专用工具理由段 解释专用工具具有权限 UI、避免原始 stdout 进入上下文 上方映射仍强制 Read / Edit / Write / Glob / Grep;理由性说明删除
Agent 的 zero-context 前缀 提醒子 agent 没看到当前对话,prompt 必须补齐上下文 同段仍有 “starts cold and re-derives context”;保留完整 briefing 规则
CronCreate 的 cron 格式与示例 五字段、本地时间和示例 CronCreateInputSchema.cron 已包含五字段、本地时间、示例及固定日期规则
Grep 的两句 shell 禁令 不用 shell grep / rg,避免绕过路径策略、输出限制和敏感文件过滤 合并为一句,规则与原因均保留
Grep 的已知路径提示 查看已知文件内容时直接用 Read 保留,并明确为 inspecting a known file's contents,不妨碍按路径搜索
Write 的父目录说明 自动创建缺失的父目录 WriteInputSchema.path 已说明
Write 的 mode 说明 默认 overwrite;append 不额外添加换行 WriteInputSchema.mode 已说明
Edit 的纯 CRLF 规则 Read 显示 LF,Edit 写回 CRLF old_string / new_string 参数说明分别保留
Edit 的混合换行规则 Read 显示 \r 时,替换内容必须使用实际 \r 参数说明保留 same Read output view 和实际 \r 规则;Read 状态块仍提示混合换行

ReadMediaFile

句子 / 段落 改前约束了什么 现在由什么约束
附件存储与 fork 说明 附件字节属于会话存储;外部转换器必须能访问服务端路径 保留附件属于当前会话及服务端路径的要求;attachmentFileSource 和实际读取逻辑不变
通用参数提醒 遵循各参数说明 参数 schema 仍随工具下发
<system> 元数据说明 返回 MIME、字节数、原始尺寸及 untouched / downsampled / crop / native 状态 buildMediaNote 在每次读取结果中动态返回这些信息
坐标规则 先给相对坐标,再按原始尺寸换算;crop 时加区域偏移 buildMediaNote 对普通图和 crop 分别返回对应坐标指引
Downsampling 与细节恢复 大图可能损失细节;用 region 或 full_resolution;无参数重读只会得到同一缩减图 downsampled 状态块给出 region 恢复指引;region / full_resolution 参数说明保留;运行时错误禁止不变重试
压缩失败与恢复 超限时不发送原图;用图像工具生成更小副本,不要重试原文件 buildImageDeliveryLimitError、buildImageDecodeLimitError 等实际报错逐字给出恢复方式
通用错误提示 文件不存在、路径非法或读取失败时会报错 运行时错误不变,无需预先解释
并行与回读 多文件尽量并行;生成或编辑媒体后必须回读 两条都保留为独立短句
文件类型与查找 只读图片 / 视频;文本用 Read;目录用 ls;模式查找用 Glob 保留 Read / Glob 短句;path schema 限制图片 / 视频;Bash 的通用目录列表规则不变
大小上限与返回形态 最大 100MB;超限报错;媒体以模型可理解形式返回 100MB 上限保留;超限报错及实际媒体返回逻辑不变

Glob

句子 / 段落 改前约束了什么 现在由什么约束
六条 pattern 示例 bare pattern 的递归含义、目录锚点、recursive walk、brace expansion 合并成三条,保留 *.ts、src/*.ts、src/**/*.ts 和两类 brace 示例;删去同义 **/*.py 示例
默认分页参数 默认 100、offset=0、head_limit=100、head_limit=0 无数量上限 GlobInputSchema 的 offset / head_limit 已说明
continuation offset 有更多结果时按返回 offset 并保持其他参数不变 正文保留一句;实际结果继续返回 offset 指引
字符上限与大结果 只返回完整路径;大结果保存文件供 Read head_limit 参数说明和实际输出提示保留
非快照与不可恢复项 每次重新搜索;分页不是快照;未采集路径无法靠翻页恢复 保留“重新搜索 / 非快照 / 部分结果需缩小重试”;offset 参数也说明结果会变化
大目录警告与示例 避免遍历依赖和构建产物,优先具体子路径 合并为一句,保留 path / pattern 收窄及 include_ignored 注意事项

TaskOutput / WaitFor / TaskList

句子 / 段落 改前约束了什么 现在由什么约束
TaskOutput 的调用场景 在 Bash / Agent / AskUserQuestion 后台调用后查进度或读完成输出;工具本身非阻塞 合并为首两句,场景和非阻塞语义均保留
TaskOutput 的通知与等待规则 优先自动通知;不要刚启动就轮询;依赖完成结果时应前台运行 保留 automatic notifications over polling 和 foreground 规则
TaskOutput 的预览与完整日志 返回元数据、有限预览和 output_path;用 Read 翻完整日志 合并为一句,并明确 output_path 存在时使用 Read
TaskOutput 的普通 shell 失败 非零退出看 exit_code,普通失败没有 stop_reason / terminal_reason formatTaskRecord 返回实际字段;执行和状态分类逻辑不变
TaskOutput 的异常终止分类 terminal_reason 区分 timed_out / stopped / failed,异常停止带 stop_reason 实际返回字段仍带这些值;无需在每次调用前展开枚举
TaskOutput 的未来任务类型 该工具是通用后台任务读取入口 工具仍走通用 task service;删除实现性说明
WaitFor 的依赖等待 只有下一步依赖运行中任务时才等待;等待期间不发 LLM 请求 两条均保留,并合并重复用法说明
WaitFor 的自动通知 不需要结果时继续其他工作,不要启动后立刻等待 保留,与 TaskOutput 的防轮询规则一致
WaitFor 的 timeout 规则 必填、秒为单位、上限 600;超时不算错误,可再次等待 timeout 参数 schema 已完整说明范围及 timeout 语义
WaitFor 省略 task_id 等待调用时已有任务中的任意一个;等待期间新任务走自动通知 task_id 参数说明保留任意已有任务语义;自动通知机制不变
WaitFor 指定 task_id 等指定任务;未知 ID 报错;已完成任务立即返回 参数说明、运行时错误和实际等待结果承接
WaitFor 空任务与批量完成 无任务立即返回;同一等待窗口完成的其他任务也会列出 保留结果包含 completed / running;实际返回逻辑不变
WaitFor 的副作用与归属 不停止任务;用户中断不停止任务;只能等当前 agent 的任务 全部保留为短句
WaitFor 的结果投递次数 已由 WaitFor 返回的结果不再重复自动通知 实际投递机制不变,删除实现性说明
TaskList 的返回字段 返回 ID、状态、描述、命令、PID、退出码和停止原因 formatTaskRecord 按实际任务返回这些字段
TaskList 的压缩恢复 压缩后或不确定时重新枚举,不猜 ID 原规则保留
TaskList 的 active_only 默认只看非终态;false 可看已结束和 lost,lost 按已终止处理 默认、false 和 lost 规则均保留
TaskList 的 limit 1–100,默认 20 TaskListInputSchema.limit 已包含默认值和范围
TaskList 与 TaskOutput 分工 TaskList 只列任务,先用它找 ID,再用 TaskOutput 读输出 首句保留 ID 指向,末句保留不返回输出
TaskList 的只读规则 不改状态,plan 模式也可安全调用 保留 read-only / safe in plan mode

其他可观测变化与验证

  • 工具描述 hash 会改变:升级后已有会话的下一次请求会有一次 prompt cache miss,之后恢复正常。
  • 参数 schema、配置键、环境变量、wire / state 契约、kap-server API 和工具执行逻辑均未修改。
  • 通用流程快照只保留工具名称和归一化后的 toolsHash;compaction 不再断言固定 token 数。
  • AgentGym(Node 24-bookworm,普通 node 用户)执行 pnpm exec vitest run --maxWorkers=15:17,926 条通过、31 skipped、0 failed;908 个测试文件通过、7 skipped。
  • Prompt 独立性验证:临时修改 agent.md 后,相关 6 个测试文件 544 条通过、1 skipped,未产生快照更新。
  • agent-core-v2 build / typecheck 与仓库 pnpm lint 通过(0 errors,既有 warnings)。
  • 本地已知 base 问题:Agent tool execution contract > returns the spawned agent id when a foreground subagent times out 在未包含本 PR 的 chore(agent-core-v2): trim built-in tool descriptions #4466 原始 head b9c27f800d 上单独运行也为 30 秒超时;本 PR 未改该执行路径。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • Confirmed this prompt-only change needs no test updates; existing behavior tests pass.
  • 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 27, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7c19153

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-28T04:25:05.565451Z 7c19153 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 27, 2026

Copy link
Copy Markdown
Contributor

@codex review

@pkg-pr-new

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

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

commit: 7c19153

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: e4785c9a73

ℹ️ 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-tool-prompts-followup branch from e4785c9 to 7c19153 Compare October 28, 2026 04:21
@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. Swish!

Reviewed commit: 7c191539bb

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