Skip to content

Fix TokenRouter Claude OpenCode protocol#433

Open
ShuxinLin wants to merge 2 commits into
mainfrom
fix/opencode-tokenrouter-anthropic
Open

Fix TokenRouter Claude OpenCode protocol#433
ShuxinLin wants to merge 2 commits into
mainfrom
fix/opencode-tokenrouter-anthropic

Conversation

@ShuxinLin

@ShuxinLin ShuxinLin commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Description

Configure OpenCode to use the Anthropic AI SDK protocol for TokenRouter Claude models instead of routing those requests through the OpenAI-compatible provider.

Fix Details

  • Detect tokenrouter/anthropic/... model IDs in the OpenCode runner provider config.
  • Use @ai-sdk/anthropic for those Claude models while keeping other router models on @ai-sdk/openai-compatible.
  • Add unit coverage for tokenrouter/anthropic/claude-opus-4.8.
  • Update CLI help to describe the TokenRouter Claude protocol behavior.

Impact on Benchmarking

  • No change to baselines: This fix only improves stability/performance.
  • Baseline change: This fix corrects a scoring error. (Please provide "Before vs. After" results).

Related Issues

Verification Steps

  1. Run the following command: uv run pytest src/agent/opencode_agent/tests/test_runner.py -v
  2. Focused OpenCode runner tests passed: 21 passed.
  3. Run Ruff on touched files: uvx ruff check ... and uvx ruff format --check ...
  4. Ruff passed: all checks passed, 3 files already formatted.
  5. uv run pytest src/ -v -k "not integration" was also run from a clean worktree, but failed on unrelated existing issues outside this change path: direct LLM JSON spacing, missing google.protobuf for observability file exporter tests, and an IoT mock DB assertion.

Checklist

  • I have added tests that prove my fix is effective.
  • My code follows the project's Ruff formatting and linting rules.
  • I have signed off my commits (DCO).

ShuxinLin added 2 commits July 8, 2026 00:13
Refs #426

Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.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.

OpenCode Claude runs fail through TokenRouter and direct Anthropic model ID

1 participant