Skip to content

fix(agent-core): suppress the spurious error event for step-capped goal turns#2217

Open
chengluyu wants to merge 1 commit into
mainfrom
fix/goal-step-cap-error-banner
Open

fix(agent-core): suppress the spurious error event for step-capped goal turns#2217
chengluyu wants to merge 1 commit into
mainfrom
fix/goal-step-cap-error-banner

Conversation

@chengluyu

Copy link
Copy Markdown
Collaborator

Related Issue

Follow-up to #2210 (which made goal pursuit continue across the per-turn step limit). The problem is explained below.

Problem

After #2210, a goal turn that hits loop_control.max_steps_per_turn no longer pauses the goal — but the TUI still renders a red, actionable error banner for every capped turn:

Error: [loop.max_steps_exceeded] Turn exceeded maxSteps=3. …
If this persists, run '/export-debug-zip' and share the file with us for diagnosis.

Root cause: runOneTurn's catch path emits a standalone error event for any failed turn (in addition to turn.ended{reason:'failed'} and the turn.interrupted{reason:'max_steps'} loop event). The TUI's session-error handler renders that event as an actionable failure. For goal-driven turns the cap is expected control flow — the driver immediately starts the next continuation turn — so the banner is pure noise that makes an intentional limit look like a malfunction.

What changed

  • In v1 TurnFlow.runOneTurn, the standalone error event is no longer emitted when the failure is loop.max_steps_exceeded and a goal is active (i.e. exactly the turns the goal driver will continue). Everything else is preserved: turn.ended{reason:'failed', error:…}, the turn.interrupted{reason:'max_steps'} loop event, the StopFailure hook, and API-error telemetry.
  • Ordinary (non-goal) turns still emit the standalone error event — a user's prompt cut by the cap must keep surfacing.
  • Tests: the v1 goal harness test now asserts capped goal turns produce zero standalone error events; the existing non-goal max-steps test now asserts the event is still emitted (right after turn.ended).
  • Includes a changeset (@moonshot-ai/kimi-code, patch).

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.

@changeset-bot

changeset-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: aefbc7f

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 26, 2026

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

commit: aefbc7f

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