Repository navigation
Description
Problem
Consult's claude review lane runs through @anthropic-ai/claude-agent-sdk (since Spec 0103). Two recurring costs:
- The SDK bundles its own copy of the Claude Code CLI. When that copy lags the model, the lane breaks (issue Repo lockfile pins @anthropic-ai/claude-agent-sdk 0.2.105; consult's claude lane gets API 400 on claude-opus-5 in local dev builds #1906: API 400 on
claude-opus-5in repo builds), independent of theclaudethe user actually has installed. - Billing surprises. Bugfix consult -m claude bills metered Opus API instead of the Claude subscription (ANTHROPIC_API_KEY shadows CLAUDE_CODE_OAUTH_TOKEN) #985 had to stop the lane billing the metered API; in workspaces whose
.envcarriesANTHROPIC_API_KEYand no OAuth token, it still bills API tokens.
Owner direction (2026-11-17): move away from the Agent SDK and go back to the claude command line tool, and for most people it should use the subscription.
Baked Decisions (architect, on the owner's ruling)
- The claude lane invokes the user's installed
claudeCLI in non-interactive print mode. The Agent SDK dependency is removed frompackages/codevonce nothing else imports it (checkpersona,dev:localand any other caller first; if another caller needs it, say so before removing). - Subscription by default. The lane uses the CLI's own login.
ANTHROPIC_API_KEY/ANTHROPIC_AUTH_TOKENfrom the environment or.envmust not reach the child process by default, so a stray key cannot silently switch billing to API tokens. API-key billing is available only as an explicit opt-in in.codev/config.json(for CI and key-only environments). The lane logs which auth it is using, as today. - Fail fast, no fallbacks: if
claudeis missing, too old, or not logged in, the lane fails loudly with what to do. It never falls back to the SDK or to an API key. - Reviewer stays read-only: the same tool allowance as today (Read, Glob, Grep), no edits, no shell. Keep the turn cap and a cost or budget cap if the CLI supports one; if it does not, say so in the spec.
- Keep what callers rely on: model selection and the per-lane model override,
--output, the VERDICT format, andconsultation_metricsrows (duration, tokens, cost, exit code, model id) taken from the CLI's structured output. - Handle the nested-session guard (
CLAUDECODEand related env) so the lane works when consult is run from inside a Claude Code session, which is the normal case. codev doctor, the consult skill and CLAUDE.md/AGENTS.md wording are updated in every tree they ship in.
Open questions for the spec
- Minimum
claudeCLI version and how it is checked. - How the lane behaves under the "Prompt is too long" failures seen today (issue consult -m claude fails with 'Prompt is too long' on a large PR (5 attempts, 2 callers, PR #1640) #1641).
- Whether PR Fix #1906: raise claude-agent-sdk floor to ^0.2.141 #1907 (SDK floor raise) is superseded; do not depend on it.
Testing
Unit tests with a stubbed claude executable for: argument construction, env scrubbing (key present in env and in .env, opt-in on and off), missing or failing CLI, metrics parsing. One live review from a worktree build, on the subscription, with the auth line shown in the PR. No live model calls in the unit suite.
Machine-load rule from the owner: run only the test files you touch while iterating, the full suite once per porch check, and never synthetic load or the local e2e suite.
Activity
[Spec 1658] Merge main (#1912 claude consult lane and doctor on the i…
[Spec 1658] M16: main's #1912 claude lane and doctor check work on na…
[Spec 1658] M16: the remaining #1912 tests on Windows (27 failures on…
[Bugfix #1906] Thread: closed, superseded by #1912; reboot checkpoint
[Bugfix #1922] Fix: launchers test never stops a Tower it did not sta…
[Bugfix #1922] Fix: adopt's merge session resolves claude too; spawn …