Skip to content

Support CLAUDE_CODE_EFFORT and CLAUDE_CODE_OAUTH_TOKEN for the Claude Code agent - #153

Open
rrailton wants to merge 2 commits into
dbt-labs:mainfrom
rrailton:claude-effort-env-var
Open

Support CLAUDE_CODE_EFFORT and CLAUDE_CODE_OAUTH_TOKEN for the Claude Code agent#153
rrailton wants to merge 2 commits into
dbt-labs:mainfrom
rrailton:claude-effort-env-var

Conversation

@rrailton

@rrailton rrailton commented Jul 20, 2026

Copy link
Copy Markdown

What

Two opt-in env vars for the Claude Code agent, in two separable commits:

  1. CLAUDE_CODE_EFFORT — appends --effort <value> (low|medium|high|xhigh|max) to the claude invocation. This is the Claude Code counterpart of OPENAI_CODEX_REASONING_EFFORT (DI-4253: support OPENAI_CODEX_REASONING_EFFORT env var #149), with the same design: an env var rather than a constructor kwarg, so no harness/factory plumbing changes. Value is shlex.quoted. Note --effort requires a recent Claude Code CLI; the setup script installs latest, so this can't regress existing runs.
  2. CLAUDE_CODE_OAUTH_TOKEN — when set (non-whitespace), the sandboxed CLI authenticates with a long-lived subscription OAuth token (from claude setup-token) instead of ANTHROPIC_API_KEY, letting subscription holders run benchmarks against their plan quota rather than metered API billing. The ab check environment anthropic preflight accepts the token too. The API key remains the default; this commit is separable if a single auth path is preferred.

Both are covered by unit tests mirroring test_openai_codex_agent.py (no-env-var, value emitted, shell-quoting; plus auth-precedence cases including whitespace-only tokens). Neither changes behavior when the env vars are unset.

Why

Same motivation as #149: comparing agents/models at matched effort levels. As a working example, we used this to run all 60 ready duckdb+dbt tasks — 75 trials per arm once per-task prompt variants are included — at 1 attempt per trial (Claude Code pinned to 2.1.207), comparing claude-fable-5 --effort low vs claude-opus-4-8 --effort xhigh:

fable-5 / low opus-4-8 / xhigh
pass@1 72.0% (54/75) 74.7% (56/75)
discordant tasks 2 4
sign test p = 0.69 (parity)
avg wall-clock/trial 85s 181s
output tokens (arm) 237k 913k

i.e. statistical parity on outcomes with a ~2x latency and ~4x token gap — the kind of readout this flag makes easy to produce.

Testing

  • pytest tests/agents/installed_agents/ — 18 passed (11 existing + 7 new)
  • Both env vars verified end-to-end in the benchmark runs above: the --effort flag is present in the recorded container commands, and OAuth auth confirmed via subscription usage accounting
  • Per-trial modelUsage audit across all 75 fable-5 trials confirmed no cross-model fallback occurred

🤖 Generated with Claude Code

rrailton added 2 commits July 20, 2026 07:57
Mirrors OPENAI_CODEX_REASONING_EFFORT (dbt-labs#149): an optional env-var override
for Claude Code's --effort level (low|medium|high|xhigh|max), useful when
comparing agents or model configurations at matched effort levels. Set via
env var rather than a constructor kwarg so the existing harness/factory
plumbing doesn't need to change.
When set, the Claude Code agent authenticates the sandboxed CLI with a
long-lived subscription OAuth token (from `claude setup-token`) instead of
an API key, letting subscription holders run benchmarks against their
plan's usage quota rather than metered API billing. ANTHROPIC_API_KEY
remains the default when the token is not set.

Also teaches the `ab check environment anthropic` preflight to accept the
token, so OAuth-only environments don't report missing credentials.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant