Repository navigation
feat(#915): evidence-based effort escalation on quality-loop retries - #926
Merged
admarble merged 6 commits intoAug 10, 2026
Merged
Conversation
Adds run.effortEscalation (default false) and a --escalate-effort flag on `sequant run`/`sequant ready`: when enabled, a retried phase execution (outer quality-loop iteration ≥ 2, or a ready-gate QA-pass retry) runs one reasoning-effort tier above its configured/inherited base, for that execution only. The resolver lives in a new effort-escalation.ts rather than beside #914's resolvePhasePolicies in config-resolver.ts, to avoid a circular import (config-resolver.ts already imports from batch-executor.ts, which needs this resolver). withEscalatedEffort clones ExecutionConfig per dispatch rather than baking an escalated value into the config at build time, so escalating one phase's retry never leaks into the next phase in the chain. Wired at the two real retry-dispatch sites: batch-executor.ts's outer quality loop and ready-gate.ts's QA-pass loop (both qa and loop sub-dispatches). Deliberately does NOT escalate phase-executor.ts's cold-start/MCP-fallback/spec-retry loops — those recover transient infrastructure failures, not evidence of task difficulty, and escalating there would burn tokens for no quality signal. Metrics: effortEscalations is a sibling array on MetricRunSchema, not an extension of #914's phasePolicies — phasePolicies is a flat per-run map and can't express a value that changes per retry.
9 tasks
…-to-end escalation-to-driver test Closes two QA-review gaps: - DEFAULT_ESCALATION_BASE was documented as an unverified assumption. Confirmed directly against @anthropic-ai/claude-agent-sdk's own query() Options type (sdk.d.ts): effort defaults to 'high'. No behavior change (the constant was already correct) — doc comment now cites the source instead of hedging. - No test proved an escalated effort survives the full chain from resolver to the SDK call. The existing per-hop tests (phase-executor.phase-policy, claude-code.phase-policy) each proved one hop for an arbitrary effort string; phase-executor.effort-escalation.test.ts chains the real resolver, the real executePhaseWithRetry, and the real ClaudeCodeDriver together, mocking only the SDK's query() call — the same boundary #914 already established, no live subprocess. Mutation-verified. Third gap raised in review (standalone 'sequant ready' never writes run metrics) is out of scope for this issue — filed as #929.
admarble
deleted the
feature/915-feat-loop-evidence-based-effort-escalation-on-
branch
August 10, 2026 00:19
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
run.effortEscalation(defaultfalse) and a--escalate-effortflag onsequant run/sequant ready: on a retried phase execution, run one reasoning-effort tier above the resolved base, for that execution only.withEscalatedEffort, cloningExecutionConfig), never baked into the config at build time — so it never leaks into a later, unrelated phase.batch-executor.ts's outer quality loop, andready-gate.ts's QA-pass loop (bothqaandloopsub-dispatches).effortEscalations, a sibling array to feat(run): per-phase model and effort configuration for the claude-code driver #914'sphasePolicies); escalations print under--verbose.Re-spec note
Spec was re-run against #914's actual merged shape (76fc911) after the prior plan — written while #914 was still open — got three integration points wrong: there is no
spec-retry.tsfile, the escalation channel isconfig.phasePolicies[phase].effort(not a separate field), and metrics needed a new sibling array rather than an extension ofphasePolicies. The updated plan is on the issue: #915 (comment)Deliberate deviations from the issue's literal AC-4 (flagged, not silent)
AC-4 names "spec retry and QA-stagnation re-runs" as the third escalation trigger, alongside the outer quality loop. Investigation during /spec found neither applies as written:
detectStagnation's own doc comment says the orchestrator should not re-invoke/qawhen stagnant — there is no re-run to escalate.In their place, the
sequant readyQA-pass loop (ready-gate.ts'sqa/loopdispatch, pass ≥ 2) was wired as the third genuine retry site in the same subsystem — a real retry loop the original AC's intent clearly covers.AC Verification
run.effortEscalation+--escalate-effortparsed, CLI > settingsrunandready); mutation-verified both producersundefined", which isn't expressible); configured phase carries its value unchangedhigh, lands onxhighDEFAULT_ESCALATION_BASE); flagged ineffort-escalation.ts's doc comment that this is an explicit assumption about the SDK's actual default, easy to revise in one place if wrongmax; ≤ one tier per retry, from configured baseeffortEscalationsmetrics array (mutation-verified aggregation), verbose print at both live sitesdocs/reference/run-command.md,docs/reference/ready-command.md,CHANGELOG.mdTest plan
npm run build— cleannpm run lint— cleaneffort-escalation.test.ts(resolver + dispatch wrapper, all AC boundary cases), cross-producer tests inconfig-resolver.phase-policy.test.ts/ready-gate.phase-policy.test.ts, live-dispatch tests inbatch-executor.test.ts, metrics tests inmetrics-schema.effort-escalation.test.ts/run-orchestrator.phase-policy.test.ts, settings schema test insettings.phase-policy.test.tsrun-orchestrator.tsCloses #915
🤖 Generated with Claude Code