fix(agent-core): continue goal pursuit when a goal turn hits the per-turn step limit#2210
Conversation
🦋 Changeset detectedLatest commit: 085b8e1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a3bf9a7cf
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba7ce8a1f0
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Related Issue
None — this is a clear, reproducible behavior fix requested by downstream users; the problem is explained below.
Problem
loop_control.max_steps_per_turncaps the steps of every turn — including goal continuation turns. Today, when a goal turn hits that cap, the turn fails withloop.max_steps_exceededand the goal driver treats it like any runtime failure: the goal is paused ("Paused after runtime error: Turn exceeded maxSteps=N…") and autonomous pursuit stops until someone resumes it.Downstream users set
max_steps_per_turnto bound each turn — and they do want goal turns bounded by it too — but they do not want the goal itself interrupted by the cap. The per-turn limit should fragment goal work into more continuation turns, not stop the goal.What changed
In both engines, a turn that fails only by reaching the per-turn step limit is no longer treated as a goal failure. The cap fires at a clean step boundary (the check runs before the next step starts), so the driver simply continues the goal with the next continuation turn, and that turn's prompt tells the model why: "The previous goal turn reached the per-turn step limit before finishing its work, so a new turn was started for you…" (followed by the usual continuation guidance).
packages/agent-core):TurnFlow.driveGoaldetectsloop.max_steps_exceededin the failed-turn branch and falls through to the normal continuation decision (goal-status and budget checks still apply) instead of pausing; theturn.endedevent still reports the failure so hosts keep full observability.packages/agent-core-v2):AgentGoalService.handleTurnEndedskips the abnormal-turn settlement for max-step failures and launches the continuation with the step-cap prompt; goal budgets (blockIfBudgetReached) still bound the pursuit.@moonshot-ai/kimi-code, patch) — both engines ship inside the CLI bundle.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.