Skip to content

feat(agent-core): tighten Write and Edit tool guidance#540

Open
chengluyu wants to merge 1 commit into
mainfrom
fix/write-edit-prompt
Open

feat(agent-core): tighten Write and Edit tool guidance#540
chengluyu wants to merge 1 commit into
mainfrom
fix/write-edit-prompt

Conversation

@chengluyu

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue; this PR addresses the tool-selection problem described below.

Problem

The file tool prompts did not make the Edit-over-Write rule forceful enough, so the model could choose Write for small edits to existing files. That risks unnecessary full-file overwrites when an exact Edit replacement is the safer tool.

What changed

  • Tightened the Write prompt so incremental changes to existing files are explicitly disallowed, including trivial and one-line edits.
  • Reworked the Edit prompt into a short description plus bullets that preserve the exact-match, ordering, and line-ending rules.
  • Updated prompt assertions so accidental weakening of the guidance is caught.
  • Added a changeset for the agent-core prompt change and the CLI bundle.
  • Raised the timeout for two git integration tests that exceeded the default 5s timeout under the full monorepo test run.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Verification

  • pnpm install --frozen-lockfile
  • pnpm test
  • pnpm --filter @moonshot-ai/agent-core run typecheck
  • pnpm --filter @moonshot-ai/kimi-code run typecheck
  • pnpm exec oxlint --quiet apps/kimi-code/test/utils/git/git-ls-files.test.ts packages/agent-core/test/tools/edit.test.ts packages/agent-core/test/tools/write.test.ts
  • git diff --check origin/main..HEAD && git diff --check
  • Read-only diff audit for internal identifiers: no issues found.

@changeset-bot

changeset-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 03a2733

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

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/agent-core Patch
@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

@chengluyu chengluyu marked this pull request as ready for review June 8, 2026 08:11
@pkg-pr-new

pkg-pr-new Bot commented Jun 8, 2026

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

commit: 03a2733

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.

1 participant