feat: add claude_code.anthropic_provider config for custom model routing#3295
Open
kilhyeonjun wants to merge 2 commits intocode-yeongyu:devfrom
Open
feat: add claude_code.anthropic_provider config for custom model routing#3295kilhyeonjun wants to merge 2 commits intocode-yeongyu:devfrom
kilhyeonjun wants to merge 2 commits intocode-yeongyu:devfrom
Conversation
Claude Code agent files (.claude/agents/*.md) use model aliases like
'opus', 'sonnet', 'haiku' which are hardcoded to 'anthropic/' prefix.
Users proxying Anthropic models through custom gateways (e.g., Kiro)
get 'Model not found: anthropic/claude-opus-4-6' errors.
Add claude_code.anthropic_provider config option that overrides the
default 'anthropic' provider prefix when resolving agent model aliases.
Example config:
{ "claude_code": { "anthropic_provider": "kiro" } }
This maps 'model: opus' -> 'kiro/claude-opus-4-6' instead of
'anthropic/claude-opus-4-6', while preserving explicit provider/model
format (e.g., 'openai/gpt-5.2') unchanged.
This was referenced Apr 10, 2026
There was a problem hiding this comment.
1 issue found across 6 files
Confidence score: 3/5
- There is a concrete regression risk in
src/config/schema/claude-code.ts:anthropic_providercurrently accepts arbitrary strings, and values with whitespace or/can generate malformed model IDs for Claude Code aliases. - Given the issue’s medium severity (6/10) and high confidence (9/10), this carries user-facing impact in provider/model resolution, so the merge risk is moderate rather than minimal.
- Pay close attention to
src/config/schema/claude-code.ts- tighten provider-name validation to prevent malformed alias model IDs.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/config/schema/claude-code.ts">
<violation number="1" location="src/config/schema/claude-code.ts:14">
P2: Validate `anthropic_provider` as a provider name instead of accepting arbitrary strings; whitespace or `/` here produces malformed model IDs for every Claude Code alias.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Address review feedback: anthropic_provider now trims whitespace, requires min length 1, and rejects values containing '/' to prevent malformed model IDs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Claude Code agent files (
.claude/agents/*.md) use model aliases likeopus,sonnet,haikuwhich are hardcoded toanthropic/prefix inclaude-model-mapper.ts. Users proxying Anthropic models through custom gateways (e.g., Kiro) getModel not found: anthropic/claude-opus-4-6errors because they don't have ananthropicprovider configured.Changes
Add
claude_code.anthropic_providerconfig option that overrides the defaultanthropicprovider prefix when resolving agent model aliases.Files Changed
src/config/schema/claude-code.tsanthropic_providerfield to schemasrc/features/claude-code-agent-loader/claude-model-mapper.tsanthropicProviderparam, use it instead of hardcodedANTHROPIC_PREFIXsrc/features/claude-code-agent-loader/loader.tsanthropicProviderthroughloadAgentsFromDir→mapClaudeModelToOpenCodesrc/plugin-handlers/agent-config-handler.tsclaude_code.anthropic_providerfrom config and pass to loaderssrc/features/claude-code-agent-loader/claude-model-mapper.test.tsanthropicProvideroverrideassets/oh-my-opencode.schema.jsonExample Config
{ "claude_code": { "anthropic_provider": "kiro" } }Behavior
"anthropic_provider": "kiro"model: opusanthropic/claude-opus-4-6kiro/claude-opus-4-6model: sonnetanthropic/claude-sonnet-4-6kiro/claude-sonnet-4-6model: haikuanthropic/claude-haiku-4-5kiro/claude-haiku-4-5model: claude-opus-4-6anthropic/claude-opus-4-6kiro/claude-opus-4-6model: openai/gpt-5.2openai/gpt-5.2(unchanged)openai/gpt-5.2(unchanged)Explicit
provider/modelformat is always preserved regardless of config.Testing
bun run typecheckpassesbun run buildsucceedskiro/providerSummary by cubic
Adds
claude_code.anthropic_providerto route Claude Code agent aliases (opus,sonnet,haiku) and bareclaude-*models through a custom provider, fixing “Model not found: anthropic/…” errors with gateways like Kiro. Adds validation to prevent malformed provider values.New Features
anthropic/prefix for aliases and bareclaude-*models.provider/modelstrings unchanged.anthropic_provider(trimmed, non-empty, no/); added tests.Migration
"claude_code.anthropic_provider": "kiro"(or your gateway) to mapmodel: opus→kiro/claude-opus-4-6.Written for commit 166e104. Summary will update on new commits.