Repository navigation
fix(codemode): Ask the model to wrap up past the turn limit on both tool paths - #2545
Merged
Merged
Conversation
…ool paths With Code Mode, the model can call a tool directly or through a `codemode` script. The turn-limit text covered only one path: - The gate blocked a direct call with "<tool> is disabled in this Turn ... Do not call it again in this Turn." The model then called the same tool through the other path. That second over-limit step hit `stop`, and the turn failed with "Agent turn exceeded execution limit". - The bridge failed a nested call past the limit with that same terminal error text, and never told the model to reply with its progress. Both paths now return one message, `TURN_LIMIT_WRAP_UP_MESSAGE`. It names no single tool, says that scripts are also disabled, and asks for a progress reply. The gate and its `wrap_up`/`stop` steps do not change. Co-Authored-By: Thomas Jiang <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
thomasjiangcy
approved these changes
Nov 2, 2026
…rn limit Co-Authored-By: Thomas Jiang <[email protected]>
Contributor
|
7 screenshot changes — 7 changed · 0 added · 0 removed Review screenshots in Frameshift |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the regression from #2544 in the integration eval
subagents.eval.ts> "when a child agent uses its turn budget, it reports its progress instead of failing". It failed live twice on run 41465177791. In both runs the child Turn failed withAgent turn exceeded execution limit (3 tool calls)and did not wrap up.What happened
With Code Mode, the model can reach a tool in two ways: a direct call or a
codemodescript. The turn-limit text covered only one of them:systemTime is disabled in this Turn. … Do not call it again in this Turn.The text names one tool. If the model then makes a tool call through the other path, that second over-limit step getsstop, and the Turn fails.Agent turn exceeded execution limit (N tool calls). It never told the model to reply with its progress.Evidence from the CI artifacts (
integration-results-2.json):/v1/messages: 9). The passing child made 5 model steps:systemTime×3, a 4thsystemTimethat was blocked, then a reply. The failing child also made 5 steps. ItssystemTimerequest count was more than 3, and it ended onstop. So the child made a tool call in the step after the wrap-up block.stopbranch inagent/index.tsthrowsTurnToolCallLimitExceededError. A local repro confirmed that the bridge's nested failures stay inside the script result.codemode" best (hypothesis b). They also fit a few other orders that mix a script and direct calls. A local repro with fixed model output gives the same failed Turn and the same error for each order.Change
services/turn-limit.ts:TURN_LIMIT_DISABLED_REASONbecomesTURN_LIMIT_WRAP_UP_MESSAGE. The text names no single tool and says thatcodemodescripts are also disabled. It still asks for a progress reply.agent/index.ts: thewrap_upblock returns that message, notdisabledToolMessage(toolCall.name, …).codemode/bridge.ts: a nested call past the limit fails with the same message, not the terminal error text.createTurnLimitGate, thewrap_up/stopsteps, bridge concurrency, or Guardian.Tests
tests/integration/codemode/bridge.test.ts: when a script reaches the limit, the call that fits runs, and later calls fail with the wrap-up message.evals/integration/agent/scripts.eval.ts: new case. When a script reaches the turn limit (maxToolCallsPerTurn: 3), the script result shows the wrap-up message, the Turn succeeds, and there is one reply.tests/cannot run the agent (test-architecture:check), so the Turn-level check is an eval.Checks
pnpm typecheck,pnpm lint,pnpm file-length:check: pass.tests/integration/codemode,tests/component/codemode,tests/unit/services,tests/component/runtime,tests/component/config, and the tool-support suites: 44 files, 388 tests pass.pnpm cli -- chatQA. This sandbox has noROACH_TOKENand no AI Gateway credentials. CI records the new eval case and runs theturn budgetcase again live. The wording change is model-facing, so CI is the real check.Open question
After a wrap-up, the gate still ends the Turn on the next tool call. If the model keeps trying after this change, the next step is a policy decision. One option is to allow a bounded second wrap-up step before
stop. I did not make that change here.via @thomasjiangcy.
--
View Session [Sentry]