Repository navigation
Description
Context
sequant run picks one agent driver for the whole run: run.agent (default claude-code), which becomes ExecutionConfig.agent. #1137 (claude-cloud driver) needs exec to run in a claude.ai cloud session and qa to run locally, because the qa skill is ~45K tokens per turn and a local run bills the subscription. Split out of #1137 by owner decision on 2026-09-24, because the change is generic and has no cloud dependency.
run.phases.<phase> (PhasePolicy, #914) holds model/effort only, and its doc comments describe it as claude-code-only. PhasePolicySchema is a plain z.object, so an undeclared agent key would be silently stripped, not rejected.
Every site that reads the run-level agent today
src/lib/workflow/phase-executor.ts:1345/1348: the skill-prompt builder (buildSkillPrompt)src/lib/workflow/phase-executor.ts:1369/1375: the driver labelsrc/lib/workflow/phase-executor.ts:1396:getPhasePromptsrc/lib/workflow/phase-executor.ts:1449: file context for file-oriented driverssrc/lib/workflow/phase-executor.ts:1598: the driver instancesrc/lib/workflow/phase-executor.ts:2050: theusesSdkMcpMCP-fallback gatesrc/lib/workflow/run-orchestrator.ts:1151/1154: the skills pre-flight (feat(run): pre-flight the skills install — missing .claude/skills/ should fail fast, not flail for 30 minutes as a spec retry #813)src/lib/workflow/config-resolver.ts:610and:631:role:resolution for phase policies and the model ladder, both resolved againstsettings.run.agentsrc/commands/doctor.ts:683/705/774: per-driver health checks
Fix shape
Add agent?: string to PhasePolicy and PhasePolicySchema. Add one resolver, resolvePhaseAgent(config, phase), which returns phasePolicies[phase].agent ?? config.agent ?? "claude-code", and make every site above read through it. Role references (role:<name>) in a phase's model, and ladder rungs applied to that phase, resolve against that phase's agent. Validate every per-phase agent name at config resolution, before the first phase runs.
Acceptance criteria
- AC-1:
run.phases.<phase>.agentsurvives settings parsing (not stripped byPhasePolicySchema) and appears on the resolvedphasePolicies— Evidence:npx vitest run src/lib/settings.phase-policy.test.ts src/lib/workflow/config-resolver.phase-policy.test.ts - AC-2: an unknown per-phase agent name fails at config resolution with the same "Unknown agent driver" message
run.agentgives, before any phase executes — Evidence:npx vitest run src/lib/workflow/config-resolver.phase-policy.test.ts src/lib/workflow/skills-preflight.test.ts(the throw and its message;RunOrchestrator.runrejecting with no worktree, pre-flight or phase) - AC-3: with
run.agent: "codex"andrun.phases.qa.agent: "claude-code", exec runs through the codex driver and qa through the claude-code driver — Evidence:npx vitest run src/lib/workflow/phase-executor.phase-agent.test.tscase asserting which driver ran each phase, the registry mocked to return real driver instances - AC-4: no file under
src/lib/workflow/readsconfig.agentexcept the resolver — Evidence:grep -rn "config\.agent" src/lib/workflow --include='*.ts' | grep -v "\.test\."prints only lines insideresolvePhaseAgent - AC-5: a phase's
role:model reference and any ladder rung applied to that phase resolve against that phase's agent, notrun.agent— Evidence:npx vitest run src/lib/workflow/config-resolver.model-roles.test.ts src/lib/workflow/model-ladder.test.tswith a driver-keyed role map and a per-phase agent - AC-6: the skills pre-flight runs when any phase's resolved driver resolves skills, not only when the run-level one does — Evidence:
npx vitest run src/lib/workflow/skills-preflight.test.tscase withrun.agent: "aider"andrun.phases.exec.agent: "claude-code" - AC-7: a resume handle created by one phase's driver is never passed to a different driver in a later phase — Evidence:
npx vitest run src/lib/workflow/phase-executor.phase-agent.test.tscase assertingresumeHandleis undefined when the driver changes - AC-8:
sequant doctorruns the driver checks for every distinct resolved agent (run-level and per-phase), not onlyrun.agent— Evidence:src/commands/doctor.test.tscase withrun.phases.exec.agent: "codex"and no codex binary, asserting the codex check is reported - AC-9: with no
agentkey anywhere,ExecutionConfigand every phase's driver are identical to today — Evidence:npx vitest run src/lib/workflow/ready-gate-run.test.ts src/lib/workflow/phase-executor.test.ts(the fix(ready-gate): driver settings never reach the gate (RunReadyGateOptions lacks the fields) — silently runs claude-code for aider/opencode configs #863 parity test is in the first) green without edits to existing cases - AC-10:
docs/reference/run-command.mddocumentsrun.phases.<phase>.agent, its precedence overrun.agent, and thatmodel/effortgo to whichever driver the phase resolves to — Evidence:grep -n "phases.<phase>.agent" docs/reference/run-command.mdnon-empty - AC-11:
npm run build && npm testgreen — Evidence: CItestjob
Non-Goals
- A CLI flag for per-phase agents (
--agents exec=…). Settings only;--models/--effortsstay as they are. sequant init --agentprovisioning for per-phase agents. Doctor reports a missing provision (AC-8), and init does not create one.- The GitHub Action's
agentinput (src/lib/ci/). - The claude-cloud driver itself (feat(drivers): claude-cloud AgentDriver — run a phase as a claude.ai cloud session instead of a nested local CLI #1137).
Graph metadata
Related
#914 (per-phase model/effort) · #975 (model roles) · #971 (model ladder) · #813 (skills pre-flight) · #674 (resume handles) · #1137
Activity
admarble commentedon Sep 25, 2026
Exec progress
PR #1163 is open. All 11 ACs are implemented and have tests; the per-AC evidence table and mutation results are in the PR body.
src/lib/workflow/phase-agent.ts, is used byphase-executor.ts,skills-preflight.ts,run-orchestrator.ts,model-ladder.ts,config-resolver.tsandcommands/doctor.ts.drivers/index.tsgainsassertKnownDriver, andPhasePolicygainsagentin both the settings schema and the resolver.phase-executor.phase-agent.test.ts. The existingphase-executor.test.tsdoesn't mock the driver registry, and mocking it there would change all its other tests.role:references and ladder rungs now resolve against the effective run-level agent (--agentincluded), notsettings.run.agent.test(#1150): AC-2 run-level rejection before any worktree; pin --agen…
admarble commentedon Sep 25, 2026
QA Review for Issue #1150
PR #1163, HEAD
c9bbe339. Reviewed in thefeature/1150-…worktree: 0 commits behindmain, clean tree.AC Coverage
settings.phase-policy.test.ts+config-resolver.phase-policy.test.ts: 28 passed.PhasePolicySchema.agentsurvives parsing, no unknown-key warning, and the key reachesphasePolicies.config-resolver.phase-policy.test.ts+skills-preflight.test.ts: 43 passed. The throw's message equalsgetDriver's. The realRunOrchestrator.runrejects with no worktree, pre-flight orrunIssuecall.resolveConfigruns beforeensureWorktrees, confirmed atrun-orchestrator.ts(resolveConfigat the top ofrun,ensureWorktreesat :1117).phase-executor.phase-agent.test.ts: 3 passed. The realCodexDriverruns exec and the realClaudeCodeDriverruns qa.phase-agent.ts:23(insideresolvePhaseAgent). The wider\.agent\bsweep ofsrc/lib/workflow,src/commandsandbinalso found no bypass.config-resolver.model-roles.test.ts+model-ladder.test.ts: 98 passed. Covers role and ladder resolution per agent, the rung-error naming the phase, codex vs claude-code escalation, and the pin rung.skills-preflight.test.ts: 27 passed. An aider run with a claude-code exec requires onlyexec, and the error names claude-code.phase-executor.phase-agent.test.ts: a codex handle reaches the codex exec and is withheld from the claude-code qa, through the realcanResume.doctor.test.ts: 66 passed. Reports "configured as agent for phase exec".ready-gate-run.test.ts+phase-executor.test.ts: 190 passed.git diffon both files is empty (no edits to existing cases).grep -n "phases.<phase>.agent" docs/reference/run-command.md: 3 lines (§ Per-Phase Agent).testSUCCESS. Localnpm test: 341 files, 8428 passed, 1 expected fail, 3 skipped. Build and lint pass.Coverage: 11/11 MET
Precheck Findings
CI Status
test,canary,typecheck,node-floor-guard,validate-skills,validate-plugin,tautology-advisoryandstructuralare SUCCESS.model-backedwas SKIPPED (secret-gated).CI Summary: 8 passed, 0 pending, 0 failed
Quality Checks (sub-agents, sequential)
any,@ts-ignoreor non-null assertions in added lines.tscis clean. No test files orexpectlines removed.assertKnownDriverusesObject.hasOwn(__proto__/constructorare rejected). The agent string never reaches a shell.Test Coverage Analysis
Every changed source file has tests. The new
phase-agent.tshasphase-agent.test.ts. The per-file mutation results are in the PR body: 4 mutations, and each fails exactly its targeted tests.Call-Site Review
The new exports are
resolvePhaseAgent,resolveRunAgent,resolvePhaseAgents,assertKnownDriver,runResolvesSkillsandladderForPhase. Each one is called:phase-executor.ts(5 sites, all keyed by the running phase);config-resolver.ts(validation and the phase-agent map);skills-preflight.tsand the orchestrator gate;model-ladder.ts(3 ladder reads);doctor.ts.No unused export. The loop in
resolveModelLadderis intended: once per distinct overriding agent.Execution Evidence / CLI Registration
N/A: no
scripts/orbin/change, and no option-interface field was added (settings-only, by the Non-Goal).Risk Assessment
--agent codexcombined with arole:model under the default (string-shorthand) roles now fails at config time. This is intended, pinned by two tests, and in the CHANGELOG, but it is a visible behavior change.sequant run, since it needs the codex binary. Dispatch is covered with real driver classes.src/lib/ci/has its ownagentinput (a Non-Goal).init.ts--agentprovisioning is run-level only (a Non-Goal).driverOverridesis read only bygetPhasePrompt, which now gets the resolved agent.config.agentread inphase-executor.ts(6 sites) was converted, as AC-4's grep confirms.Trust-Boundary Check
Finding: Clean. The diff implements only the issue's product requirements; no agent-directed external-text instruction was acted on.
Status: Clean
Behavior-Rule Survival Check
Status: N/A.
detectBehaviorRuleran on all 11 stored ACs of #1150 this pass and none triggered.Declared-Evidence Execution
Status: Complete. All 11 evidence commands were run verbatim this pass, with results as in the AC table.
Mutation Verification
Status: Not-Applicable. No AC is a gate test under
isGateTestEvidence. The PR body records 4 mutations anyway.CHANGELOG Verification
Added: a per-phase agent entry (#1150). Fixed:
role:follows--agent(#1150). Result: met.Adversarial Re-Read
Findings:
src/lib/settings.ts(near :1782) has nophasesrow at all (missing since feat(run): per-phase model and effort configuration for the claude-code driver #914), sorun.phases.<phase>.agentisn't listed there. Itsagentrow also omitscodex.docs/reference/run-command.mddoes document the key. This is a one-row fix.npm testin this worktree, some test rewrote the checkout's real.sequant/state.jsonto an empty state at 14:20. feat(run): per-phase agent selection — run.phases.<phase>.agent #1150's stored ACs vanished mid-QA and I restored them. I ran all three new test files alone and none touches it; the rewrite carries alastSyncedstamp, which suggests a reconcile path. Worth an issue: running the suite in a real checkout silently wipes its workflow state.Also checked:
src/lib/ci, cloud driver — none touched.Status: Gaps Found (both pre-existing, non-blocking)
Verdict: AC_MET_BUT_NOT_A_PLUS
All 11 ACs are MET with their evidence commands executed, CI is green, and the full suite passes. It isn't A+ because of the two pre-existing gaps above. Gap 1 is a one-line doc fix that could land in this PR. Gap 2 should be its own issue. Neither blocks merge.
Documentation
phases(gap 1)Next Steps
phasesrow, notingagent/model/effort, to the settings reference table insrc/lib/settings.ts..sequant/state.json.docs(#1150): settings reference lists run.phases (agent/model/effort)…
test(#1150): state-utils rebuild test no longer writes the checkout's…
feat(#1150): per-phase agent selection — run.phases.<phase>.agent (#1163