MPS: resolve relayed --model against a curated target allowlist - #435
Open
masonc08 wants to merge 2 commits into
Open
MPS: resolve relayed --model against a curated target allowlist#435masonc08 wants to merge 2 commits into
masonc08 wants to merge 2 commits into
Conversation
A relayed (Claude Max/Team/Enterprise subscription) Model Provider Service is a subscription relay: the AI Gateway passes the client's requested model through to Anthropic and, for Team/Enterprise, validates it against the service's allowlist (only personal Max skips that) -- it never selects a model server-side. Real Enterprise relays are allow_all_targets with no declared Claude targets, so there is nothing for ucode to resolve --model against. So for a relayed provider, forward --model to Claude Code's own --model flag -- exactly what 'ucode claude --provider <mps> -- --model X' already does, now automatic. Claude Code selects the model natively and the relay honors it. Non-relayed providers (API-key / Bedrock) keep the env-pinning path unchanged. Verified end-to-end against a relayed Enterprise MPS: '-- --model opus' launches on Opus via the subscription. Co-authored-by: Isaac <no-reply@databricks.com>
masonc08
force-pushed
the
masonc08/mps-relayed-allowlist
branch
from
September 1, 2026 15:10
e9fe90f to
20eb50f
Compare
Follow-up to #427 (which forwards --model to Claude Code for a relayed provider). That covers allow_all relays; a relayed Team/Enterprise service that declares a curated model allowlist still needs its --model reconciled against those targets, since the AI Gateway enforces them -- forwarding a bare alias or Claude Code's subscription default can 403. For a relayed provider, resolve --model (and the bare-launch default) against the declared targets, then forward the resolved id via Claude Code's own --model flag: --model opus -> the declared opus target; no --model -> the best allowed tier; an allow_all relay declares nothing -> forward as-is (unchanged). Stops exempting relayed in resolve_provider_models; adds resolve_provider_launch_model always_select (relayed has no pinned family alias to fall back on). Unit-tested; the curated-allowlist path is not e2e-verified (real relays we've seen are allow_all). One assumption to confirm live: Claude Code's --model accepts a full canonical id (e.g. claude-opus-4-8), not only opus/sonnet/haiku aliases. Co-authored-by: Isaac <no-reply@databricks.com>
masonc08
force-pushed
the
masonc08/mps-relayed-allowlist
branch
from
September 1, 2026 15:16
20eb50f to
d0e701f
Compare
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.
Stacked on #427.
Problem
#427 forwards
--modelto Claude Code's own flag for a relayed provider — right forallow_allrelays (the common Enterprise shape). But a relayed Team/Enterprise service that declares a curated model allowlist still breaks:--model opusis forwarded verbatim; if Claude Code'sopusalias resolves to an id that isn't byte-for-byte the declared target, the gateway 403s.The gateway enforces the allowlist for Team/Enterprise (
ExternalModelDirectClient.isModelAllowed), so the forwarded id must be one the service declares.Change
For a relayed provider, resolve
--model(and the bare-launch default) against the declared targets, then forward the resolved id via Claude Code's--modelflag:--model opus→ the declared opus target,--model→ the best allowed tier (so it doesn't dead-end on a forbidden default),allow_allrelay (no declared targets) → forward as-is (unchanged from MPS: forward --model to Claude Code for a relayed provider #427).Mechanics:
resolve_provider_modelsno longer exempts relayed — it maps declared targets like any Anthropic service (allow_allyields none).resolve_provider_launch_modelgainsalways_select, since a relayed launch forwards via Claude Code's flag and has no pinned family alias to fall back on when opus is present.Testing
test_cli(alias → declared target, auto-pick best tier, unavailable-family error);resolve_provider_modelsmaps relayed targets (test_agents_init);always_select(test_databricks). 734 green,ruffclean.allow_all. One assumption to confirm live: Claude Code's--modelaccepts a full canonical id (e.g.claude-opus-4-8), not onlyopus/sonnet/haikualiases. If it doesn't, we'd forward the family alias for relayed instead.This pull request and its description were written by Isaac.