Repository navigation
feat(#733): graceful error_max_turns handling for subagents - #737
Merged
admarble merged 3 commits intoJun 22, 2026
Merged
Conversation
When a subagent hits its maxTurns cap, ClaudeCodeDriver previously treated error_max_turns as a hard failure, discarding the partial work already produced. Turn caps are live on every agent (#484), so this is a real, reachable failure mode. - AC-1: add additive `capped?: boolean` to AgentPhaseResult; on error_max_turns the driver warns (via onStderr) instead of erroring and returns the partial output flagged `capped: true`, with no hard error string. Branched out of the error-subtype switch. Unit test added. - AC-2: /qa treats a turn-capped check as inconclusive (flagged in the summary, not a phase failure on the cap alone). - AC-3: /exec treats a turn-capped implementer as incomplete (reports finished-vs-capped tasks for the next iteration to resume). Orchestrator-level partial preservation in phase-executor is out of scope (sub-agent caps only). Skill changes synced across all three mirrors. Entire-Checkpoint: 12702c080a1d
3 tasks
…anch /testgen follow-up: AC-1's happy-path unit test already exists. Add the inferred failure path the spec's verification implies — prove the new error_max_turns branch is narrow: other error subtypes (error_during_ execution) still fail hard (success:false, real error string, no capped flag), so soft-cap handling can't mask a genuine failure. Refactor the mocked SDK result to be configurable via vi.hoisted; reset in beforeEach. Entire-Checkpoint: 5a81b6733c70
…error-max-turns-handling-for-subagents # Conflicts: # CHANGELOG.md # src/lib/workflow/drivers/agent-driver.ts # src/lib/workflow/drivers/claude-code.test.ts
This was referenced Jun 22, 2026
admarble
deleted the
feature/733-graceful-error-max-turns-handling-for-subagents
branch
June 22, 2026 13:57
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.
Summary
When a subagent hits its
maxTurnscap,ClaudeCodeDriverpreviously treatederror_max_turnsas a hard failure (error: "Max turns reached"), discarding whatever partial work the agent had already produced. Turn caps are live on every agent (#484), so this is a real, reachable failure mode that wastes completed work. This change makes the cap a soft, recoverable outcome.capped?: booleantoAgentPhaseResult. Onerror_max_turnsthe driver now warns (via theonStderrchannel) instead of erroring and returns the partialoutputflaggedcapped: true, with no hard error string. Branched out of the error-subtype switch so it never carrieserror./qa: a turn-capped spawned check is flaggedNEEDS_VERIFICATION, notAC_NOT_MET)./exec: a turn-capped implementer is treated as incomplete, reporting which tasks finished vs. which were capped so the next iteration resumes them.Out of scope (per spec): orchestrator-level partial preservation in
phase-executor.ts(the failure path still discards onsuccess: false) — confined to the driver + skills as scoped; settings/CLI cap overrides remain blocked on #632 /anthropics/claude-code#43869.Pre-PR AC Verification
capped: trueclaude-code.ts:178-191,agent-driver.ts:70-77; testclaude-code.test.ts:46-86/qacapped check → inconclusive, not phase failureqa/SKILL.md"Turn-Capped Checks → Inconclusive" (×3 mirrors)/execcapped implementer → incomplete, finished-vs-cappedexec/SKILL.md§4b2 "Detecting Turn-Capped Implementers" (×3 mirrors)Test plan
npm run build— passes (tsc clean)npm run lint— passes (0 warnings)npm test(drivers + phase-executor) — 179 passed, 2 skippedcheck-skill-sync.ts— qa/exec SKILL.md mirrors in sync (pre-existing divergences elsewhere are unrelated)lint:skill-calls— no violationserror_max_turns→ partial output +capped: true, no hard error, warns viaonStderrCloses #733