fix(selfhost): route single-provider AI through the name-aware router (#1610) - #1611
Merged
Merged
Conversation
…#1610) A single-provider self-host (e.g. AI_PROVIDER=claude-code) failed every AI review with an opaque claude_code_exit_1. resolveAiReviewerPlan addresses the lone reviewer by provider name ({ model: "claude-code" }) — the same router address convention as the 2-provider plan — but createSelfHostAi returned the BARE provider for a single provider, bypassing routeProviders's name-stripping. So createClaudeCodeAi ran resolveModel(undefined, "claude-code", ...), which passes "claude-code" through verbatim (it only strips @cf/ ids), producing `claude --model claude-code` → 404 → exit 1, three attempts, then exhausted. Wrap a single provider in routeProviders too, so the provider-name address resolves to the provider's own default model. Regression test pins that a single-provider env.AI.run(<providerName>) sends the provider default, never the literal provider name as a model id.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1611 +/- ##
==========================================
- Coverage 95.51% 95.51% -0.01%
==========================================
Files 204 204
Lines 22042 22041 -1
Branches 7964 7963 -1
==========================================
- Hits 21053 21052 -1
Misses 413 413
Partials 576 576
🚀 New features to boost your workflow:
|
This was referenced Jun 27, 2026
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
Single-provider self-host reviews (
AI_PROVIDER=claude-code) failed 100% with an opaqueclaude_code_exit_1. Root cause:resolveAiReviewerPlanbuilds the single-provider plan asreviewers: [{ model: "claude-code" }]— the reviewer "model" is the router address (the provider name), matching the 2-provider convention. ButcreateSelfHostAireturned the bare provider for a single-provider setup, bypassingrouteProviders's name-stripping. SocreateClaudeCodeAi.run("claude-code", …)ranresolveModel(undefined, "claude-code", "claude-sonnet-4-6"), which returns"claude-code"verbatim (it only strips@cf/ids) →claude --model claude-code→ 404 (is_error:true, api_error_status:404, "There's an issue with the selected model (claude-code)"), exit 1, three times, thenai_review_provider_exhausted.Verified in-container:
claude --model claude-code⇒ exit 1 / 404;claude --model claude-sonnet-4-6(what the router yields) ⇒ exit 0. The 2-provider path already worked becauserouteProvidersstrips the name (its test documents exactly this: "the router never passes the provider NAME through as a model id").Fix:
createSelfHostAiwraps a single provider inrouteProviderstoo, so the provider-name address resolves to the provider's own default model. One-line behavior change (delete thelength === 1bare-return) plus a regression test that pins it. No public behavior, schema, binding, or migration change.Closes #1610.
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥97% coverage of the lines AND branches you changed (aim for 98%+ on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
ui:openapi), nowrangler.jsoncbinding/var change (cf-typegen), no DB change (migration).Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots. — N/A: no visible UI change.Notes
routeProvidersname-stripping that already covers the 2-provider/dual-review path; it makesenv.AIuniformly name-aware so a reviewer-plan address never reaches a provider as a literal--model.