Repository navigation
[EPIC-U][LOU-U19] Hitting maxSteps yields finishReason 'max-steps' - #83
Merged
Merged
Conversation
When the agent loop spends its maxSteps budget while the model still wanted to continue, the result, finish event and run.done now report 'max-steps' instead of the stale last-turn reason. initialSteps / approval resumes count toward the budget. Consumers that inferred a cut-off from 'tool_calls' (eval completed() message, sub-agent task failure, MCP agent tool) use 'max-steps'. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016bY29ibQgv3MDdjAbUT4YR
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.
What
ExecutionFinishReasongains'max-steps'. InAgentExecutor.runSteps(), leaving the step loop without the model having stopped (and without an abort) setsfinishReason = 'max-steps'beforefinishRun(). The result, thefinishevent andrun.done(which readsresult.finishReason) all carry it; no edits to agentEvents.ts or agentRun.ts were needed.initialStepsand approval resumes count toward the budget; resume.ts is untouched.completed()hint now keys on'max-steps'(was'tool_calls'), sub-agenttaskfailure message recognises'max-steps', and the MCP server's agent tool returns an error result instead of an empty success. Forge status mapping needed no change (non-approval results map tostopped).step.done/run.donerows, CHANGELOG entry, regenerated llms-full.txt.Why
A run that exhausted
maxStepsexited silently with the last step'sfinishReason(oftentool_calls) and possibly empty text, so callers could not tell a completed run from an exhausted one.Acceptance criteria
'max-steps'added toExecutionFinishReason; reported when the budget is exhausted while the model still wanted to continue; natural completion unchangedrun.donefromagent.stream()/AgentExecutor.streamcarries the reason, no agentEvents.ts editsinitialSteps, approval resume) count correctly; a resume that immediately exhausts reports'max-steps'; resume.ts untouchedExecutionResult.stepskept; documented in docs/api-overview.md and docs/streaming.md; llms files regeneratedfinishReasonconsumers checked (src, apps/agent-forge, examples, packages); three one-line updates, none brokenmockModel: always-tool model withmaxSteps: 2gives'max-steps'andsteps === 2;run.donecarries it; text reply on exactly the last allowed step is'stop'; resume paths (new src/execution/maxSteps.test.ts)How verified
npx tsc --noEmit: no errorsnpm run lint: 0 errors, 433 warnings (same as main)npm run test:types: no type errorsnpx vitest run(after build): 141 files passed, 2064 passed / 3 skippednpm run build && npm run build --workspace=packages/create-loushy-agent: successnpm run docs:verify-snippets -- --skip-build: all 96 snippets type-checknpm run docs:llms:check: passnpm run test:coverage: 141 files passed, 2064 tests passednpm run fallow: exit 0, dead code none (one pre-existing duplicate group in src/providers)🤖 Generated with Claude Code
https://claude.ai/code/session_016bY29ibQgv3MDdjAbUT4YR
Generated by Claude Code