Skip to content

chore(agent-core-v2): remove mandatory Edit and Bash sed restrictions - #4609

Merged
7Sageer merged 2 commits into
mainfrom
chore/remove-bash-sed-restriction
Nov 2, 2026
Merged

7Sageer merged 2 commits into
mainfrom
chore/remove-bash-sed-restriction

Conversation

@7Sageer

@7Sageer 7Sageer commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

当前 Bash、Edit 和 Write 的工具描述共同要求增量编辑必须使用 Edit,并明确禁止 Bash sed。本次按直接需求移除这些提示词约束,使模型不再受到这层工具选择限制;不改变工具运行时实现或权限行为。无关联 issue。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

 Edit description
-  Require Edit for every incremental change.
-  Do not use Write or Bash sed.

 Bash description
-  Redirect sed/awk in-place edits to Edit.

 Write description
  Keep Write scoped to new files, complete replacements, and low-continuity content.
- Require Edit for every incremental change to an existing file.

本次只删除或收窄工具提示词,不改动工具参数、执行逻辑或权限检查。共享测试快照层对 tool_select.initialized 只保留工具名,避免把 description 和 parameters 原文作为测试契约;四个测试文件中的 7 处内联快照同步更新,并添加 CLI patch changeset。

Behavior Changes and Affected Users

下表中的“所有客户端用户”具体指通过 TUI、print 模式、desktop/web、VS Code、ACP 或 SDK 使用内置 agent 工具描述的用户。

Behavior Before After Who relies on the old behavior Escape hatch
Edit is mandatory for every incremental change, especially small edits. 每次增量编辑都必须使用 Edit。 删除该强制要求;Edit 仍提供精确替换能力。 依赖模型始终使用专用 Edit 工具的所有客户端用户。 无;需维护者明确确认接受该行为移除。
DO NOT use Write or Bash sed. Edit 描述明确禁止使用 Write 或 Bash sed。 不再由 Edit 描述禁止这两种方式;Write 自身适用范围仍保留。 依赖该禁令避免整文件写入或 shell 编辑的所有客户端用户。 无;需维护者明确确认接受该行为移除。
sed / awk (in-place edit) → Edit Bash 描述将 sed / awk 原地编辑定向到 Edit。 Bash 描述不再重定向;工具权限规则保持不变。 依赖 Bash 工具描述阻止 sed / awk 原地编辑的所有客户端用户。 无;需维护者明确确认接受该行为移除。
use Edit for every incremental change to an existing file Write 描述再次强制所有增量编辑使用 Edit。 删除该分句;Write 仍仅用于新文件、完整替换或低连续性内容。 依赖 Write 描述保证增量编辑走 Edit 的所有客户端用户。 无;需维护者明确确认接受该行为移除。

四行提示词变化不再由原文断言守护;相关测试仅保留工具名与所在用例的非文本行为覆盖。本 PR 不涉及 API、配置、会话数据、provider 方言或平台分支变化。

验证详情
pnpm exec vitest run \
  packages/agent-core-v2/test/tool/tool.test.ts \
  packages/agent-core-v2/test/agent/loop/loop.test.ts \
  packages/agent-core-v2/test/app/config/config.test.ts \
  packages/agent-core-v2/test/features/plan/plan.test.ts \
  -t '^(?!.*returns the spawned agent id when a foreground subagent times out).*$' -u

结果:4 个测试文件通过,374 个测试通过,1 个测试跳过。returns the spawned agent id when a foreground subagent times out 在本分支与未修改的 main 上均以相同的 30 秒超时失败,因此定向验证中排除了该既有失败;本 PR 未修改其实现或测试。未运行全量测试。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve). — N/A:无关联 issue,本 PR 来自直接需求。
  • 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. — 行为表与 changeset 已覆盖;无退路的提示词删除仍待维护者明确确认。
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update. — 公开文档未描述这些内部工具提示词,无需更新。

Copilot AI balanced review requested due to automatic review settings November 2, 2026 08:42
@changeset-bot

changeset-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1f37966

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

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. Try requesting a review at a lower effort level.

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.

@7Hanrui

7Hanrui commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 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-11-02T09:07:37.638926Z 1f37966 Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 3d428b0ef4

ℹ️ 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 Nov 2, 2026

Copy link
Copy Markdown
Contributor

@codex review

@7Sageer
7Sageer marked this pull request as ready for review November 2, 2026 09:00
@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026

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

commit: 1f37966

@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: 1f37966a62

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

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

Stop requiring Edit and prohibiting Bash `sed` for incremental file edits.

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 Gate the prompt-policy removal on maintainer approval

For all clients receiving these built-in tool descriptions, this change removes the Edit-only and no-sed restrictions without an opt-out. The commit message marks the required maintainer approval as still pending, so users relying on the old behavior have no way to retain it; obtain explicit approval before shipping or provide an escape hatch.

AGENTS.md reference: AGENTS.md:L116-L120

Useful? React with 👍 / 👎.

const args = event.args as { readonly tools: readonly { readonly name: string }[] };
stableEvent = {
...event,
args: { ...args, tools: args.tools.map((tool) => tool.name) },

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 tool descriptions in the prompt snapshots

Replacing each tool_select.initialized tool with its name removes descriptions from these snapshots, which were the general snapshots retaining tool prompt text. The generate-input snapshots also record only tool names, so future regressions in Edit, Bash, or Write guidance will no longer fail these tests; retain the descriptions or add targeted assertions for these prompts.

AGENTS.md reference: AGENTS.md:L118-L120

Useful? React with 👍 / 👎.

@7Sageer
7Sageer merged commit fc3b521 into main Nov 2, 2026
18 checks passed
@7Sageer
7Sageer deleted the chore/remove-bash-sed-restriction branch November 2, 2026 09:11
@github-actions github-actions Bot mentioned this pull request Nov 3, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
Port of upstream fc3b521 (MoonshotAI#4609). Two prompt lines told the model to use
Edit for every incremental change and forbade Write and Bash `sed`, which
made the tools fight each other: a `sed -i` one-liner is sometimes the
honest way to change many files, and a wholesale Write is sometimes clearer
than a chain of edits. Both lines are gone; Write keeps its own guidance
about when a full replacement is appropriate.

Local-form notes: the fork's `bash.md` has no `sed`/`awk` → Edit mapping to
remove, so only `edit.md` and `write.md` change. No test in the tree
snapshots these descriptions (verified by grep for both sentences), so
upstream's companion "stop snapshotting tool descriptions" change has no
local counterpart and the tool, plan, config and loop suites pass unchanged.

Verified: check-prompt-ownership and check-no-comments pass; tool 194 pass,
plan included; config + loop 188 pass.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 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.

4 participants