Repository navigation
feat(#739): preserve partial output for turn-capped phases in phase-executor - #741
Merged
admarble merged 3 commits intoJun 23, 2026
Conversation
…xecutor #733 made the driver return a soft `capped` result for `error_max_turns`, but at the orchestrator level the flag was dead data: phase-executor's failure return dropped both `capped` and the partial `output`, so a top-level phase query that hit its turn cap discarded its work. - AC-1: add additive `capped?` to `PhaseResult` and propagate it plus the partial `output` on the failure return (output was previously dropped). - AC-2: short-circuit `executePhaseWithRetry` on a capped result before the cold-start retry, MCP fallback, and spec-extra retry — a retry cannot un-cap a turn limit (mirrors the #732 billing skip, but via explicit early return since capped must skip cold-start retries too). Belt-and-suspenders `!failureIsCapped` guard at the MCP gate. - AC-3: run loop surfaces a distinct "turn cap reached — partial output preserved" signal (not a generic failure), persists the partial output and an additive `capped` marker on the phase log (status stays "failure"), and halts cleanly — skipping both the inner /loop spawn and the outer quality-loop retry so it never acts on incomplete work. - AC-4: capped-path tests in phase-executor.test.ts (flag + output preserved, single invocation / no MCP fallback, no spec-extra retry) and batch-executor.test.ts (distinct signal, capped log marker, clean halt, quality-loop skip). Entire-Checkpoint: c5a9668ff2b8
4 tasks
…ng site QA (#741) found the AC-3 run-loop signalling was applied only to the main phase loop. The spec phase has its own failure-handling block, so a capped spec phase preserved partial output and halted cleanly but emitted a generic "unknown" signal and omitted the `capped` log marker — making it indistinguishable from a real failure. Mirror the main loop in the spec block: - distinct "turn cap reached — partial output preserved" progress signal - pass `capped: specResult.capped` to the spec phase log Adds a batch-executor test for a capped spec phase (distinct signal, capped log marker, clean halt, partial output preserved). Entire-Checkpoint: 469a5a4b8160
Address two gaps found in review of PR #741: 1. Output scope creep: phase-executor's failure return propagated the partial output unconditionally, silently injecting a 2000-char output tail into the /loop fix-context (formatFailureContext) for every genuine (non-capped) failure — behaviour that never existed pre-#739 and was outside the issue's scope. Gate output on capped, extracted into a unit-tested mapAgentFailureToPhaseResult helper symmetric to mapAgentSuccessToPhaseResult. 2. Capped marker not persisted to state: a turn-capped halt was recorded in .sequant/state.json as a plain "failed" phase, indistinguishable from a genuine failure on resume (only the run-log carried capped). Add an additive capped field to PhaseStateSchema and thread it through updatePhaseStatus and the two batch-executor call sites, making the PR's 'reversible later' resume path first-class. Tests: non-capped failure drops output (phase-executor.test.ts), capped marker persisted/unset (state-manager.test.ts). Full workflow suite green (948 passed), lint clean.
admarble
deleted the
feature/739-feat-orchestrator-preserve-partial-output-for-turn
branch
June 23, 2026 04:01
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
Completes the follow-up carved out of #733. At the orchestrator level the driver's
cappedflag was dead data:phase-executor's failure return dropped both the flag and the partialoutput, so a top-level phase query (not a spawned sub-agent) that hit itsmaxTurnsceiling discarded its work exactly as before #733.PhaseResultgains an additivecapped?: boolean(same shape asstructuredError?from feat(driver): surface structured rate-limit/credits errors from SDK message stream (replaces #592 fallback noise) #732); the failure return now propagatescappedand the partialoutput(previously omitted on failure).executePhaseWithRetryshort-circuits a capped result before the cold-start retry, the MCP fallback, and the spec-extra retry — a retry cannot un-cap a turn limit (mirrors the feat(driver): surface structured rate-limit/credits errors from SDK message stream (replaces #592 fallback noise) #732 billing skip, but uses an explicit early return since capped must skip cold-start retries too).turn cap reached — partial output preservedprogress signal (not a generic failure), partial output persisted tophaseResults+ an additivecappedmarker on the phase log (status stays"failure", no new enum value), and the run halts cleanly — skipping both the inner/loopspawn and the outer quality-loop retry so it never acts on incomplete work.Pre-PR AC Verification
PhaseResultcarriescapped+ partialoutputfrom a capped driver resulttypes.ts:223(capped?);phase-executor.ts:765-767(propagatecapped+output)phase-executor.ts:854,882(early returns);:947(!failureIsCappedMCP guard)batch-executor.ts:886-893(distinct signal),:948(log marker),:987+:1068(skip inner /loop + outer quality-loop)phase-executor.test.tscovers the capped path end-to-endphase-executor.test.ts(3 capped cases) +batch-executor.test.ts(2 AC-3 integration cases)Design decision (AC-3, open question in spec): chose surface + halt per the spec recommendation — auto-continuing on partial work is risky. Reversible later via the now-first-class
cappedflag.Log-schema decision: added an additive optional
cappedboolean toPhaseLogSchemaand reused the"failure"status rather than introducing a newPhaseStatusenum value — keeps the persisted-log schema stable (spec Open Question #2 recommendation).Test plan
npm run build— passes (tsc clean)npm run lint— passes (0 warnings)npx vitest run src/lib/workflow/— 943 passed, 2 skipped__tests__/run-orchestrator*.test.ts) — 48 passedCloses #739
🤖 Generated with Claude Code