Skip to content

fix(agent-core): count validation-rejected tool calls toward the repeat breaker - #2313

Merged
7Sageer merged 2 commits into
MoonshotAI:mainfrom
starquakee:fix/agent-core-dedup-register-rejected-calls
Jul 28, 2026
Merged

fix(agent-core): count validation-rejected tool calls toward the repeat breaker#2313
7Sageer merged 2 commits into
MoonshotAI:mainfrom
starquakee:fix/agent-core-dedup-register-rejected-calls

Conversation

@starquakee

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — explained below.

Problem

The repeat breaker only counts calls that reach prepareToolExecution. Calls rejected by args validation return earlier and never register, so re-issuing the same invalid call gets no reminders and no stop — the turn only ends at maxSteps, burning a provider request per step.

Reproduction (test/agent/turn.test.ts): 12 identical Bash calls missing the required command + one trailing text response. Before: the turn consumes the 13th generation. After: it stops at exactly 12 with the full none → r1×2 → r2×3 → r3×4 → stop escalation chain.

What changed

  • tool-dedup.ts: add registerSkipped() for calls that bypassed prepareToolExecution (no-op when already registered).
  • turn/index.ts: call it in finalizeToolResult, a hook every call passes through.
  • Tests: dedup-level (force-stop at 12 keeping the error flag; no double registration) and the turn-level reproduction above.

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.

…at breaker

Args-rejected calls returned before prepareToolExecution, so the breaker
never counted them and the model could re-issue the same invalid call
until maxSteps. Register them in finalizeToolResult so reminders fire at
3/5/8 and the turn force-stops at 12.
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4e4f2d3

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/agent-core 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

@pkg-pr-new

pkg-pr-new Bot commented Jul 28, 2026

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

commit: 4e4f2d3

@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: d58e0e4a94

ℹ️ 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 thread packages/agent-core/src/agent/turn/index.ts Outdated
Malformed JSON arguments normalize to {} on parse failure, which keyed
every malformed-but-different attempt identically and could force-stop a
turn whose calls were evolving rather than identical. Register skipped
calls on the raw arguments text when parsing failed.
@7Sageer
7Sageer merged commit de0ba9d into MoonshotAI:main Jul 28, 2026
14 checks passed
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