Skip to content

Conversation

@hyf0
Copy link

@hyf0 hyf0 commented Feb 9, 2026

Summary

  • Add CLAUDE_CODE_OAUTH_TOKEN support to the claude-code agent, enabling Claude Pro/Max subscription users to run evals without a separate ANTHROPIC_API_KEY
  • When CLAUDE_CODE_OAUTH_TOKEN is set in the environment, it is used for both API key resolution (getApiKeyEnvVar()) and sandbox env passthrough
  • AI Gateway users are unaffected — the OAuth token path is only used for direct (non-gateway) configurations

Closes #54

Test plan

  • npm run build passes
  • npm run lint passes
  • Manual test: set CLAUDE_CODE_OAUTH_TOKEN (without ANTHROPIC_API_KEY) and run an eval — agent should authenticate via OAuth
  • Manual test: set only ANTHROPIC_API_KEY — existing behavior unchanged
  • Manual test: set AI_GATEWAY_API_KEY with useVercelAiGateway — AI Gateway path unchanged

🤖 Generated with Claude Code

Allow Claude Pro/Max subscribers to authenticate using their OAuth token
instead of requiring a separate ANTHROPIC_API_KEY. When CLAUDE_CODE_OAUTH_TOKEN
is set in the environment, it takes precedence over ANTHROPIC_API_KEY for
non-AI-Gateway configurations.

Closes vercel-labs#54

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 9, 2026 08:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for authenticating the claude-code agent via Claude Code’s OAuth token (CLAUDE_CODE_OAUTH_TOKEN) so Claude Pro/Max users can run evals without an ANTHROPIC_API_KEY, while keeping the AI Gateway path unchanged.

Changes:

  • Update claude-code agent API key env-var resolution to prefer CLAUDE_CODE_OAUTH_TOKEN (direct mode only) when present.
  • Update sandbox command env passthrough to send CLAUDE_CODE_OAUTH_TOKEN instead of ANTHROPIC_API_KEY in the OAuth case.
  • Add a changeset documenting the patch release.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/agent-eval/src/lib/agents/claude-code.ts Adds OAuth token selection in getApiKeyEnvVar() and passes OAuth env var into the sandbox for claude runs.
.changeset/oauth-token-support.md Declares a patch release and documents OAuth token support for claude-code auth.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Refactor nested ternary for sandbox env to if/else for readability,
add clarifying comment about credential consistency, and add unit
tests for getApiKeyEnvVar() precedence (gateway > oauth > direct).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Support CLAUDE_CODE_OAUTH_TOKEN for Claude Code agent

1 participant