Repository navigation
fix(openai): honor model_routing for Codex manifests and scheduling - #6688
Merged
Wei-Shaw merged 1 commit intoSep 7, 2026
Merged
Conversation
An OpenAI group that keeps a failover account for a shared public alias
produced a Codex model descriptor with no reasoning levels and text-only
input, which leaves the client's reasoning-effort slider with nothing to
select.
Two accounts explicitly mapping one alias to different upstream models
makes codexExplicitModelTargetsConflictForPlatform true. With no
upstream_model_metadata snapshot to intersect, groupCodexModelMetadata
short-circuits to {reasoningConflict, inputModalitiesConflict}, so
DefaultReasoningLevel is nil (the key vanishes under omitempty) and
SupportedReasoningLevels is an empty array. mergeMissingCodexModelFields
fills only missing-or-null fields, so an empty array is never repaired.
Failing closed is right when the alias target is genuinely ambiguous, but
a group that declares model_routing for the alias has already resolved
that ambiguity: the operator stated which accounts serve it and which is
primary. Treating that as a conflict rejects a deliberate failover setup.
Manifest side: when a routing rule names the alias, restrict capability
declaration to the routed accounts and skip the conflict override.
Capabilities then fall back to the same by-name derivation used for a
single account without a metadata snapshot. Groups with no rule, a
disabled rule, or a rule for another alias keep failing closed.
Scheduling side: model_routing was stored and read platform-agnostically
(admin_group.go, Group.GetRoutingAccountIDs) but four gates in
gateway_scheduling.go only consulted it for Anthropic, so an OpenAI
group's rules were accepted and displayed yet never honored. Without
this, the manifest would honor a rule that scheduling ignores. Both
gates now share one predicate, with the allowed platform set defined in
a single place.
Selection inside a routing list is unchanged: the list is a membership
set, and the winner is still decided by Priority, then load, then
LastUsedAt.
Tests: alias-failover manifest recovery plus the three negative cases,
the platform predicate table, and an OpenAI routed selection that must
beat a higher-priority unrouted account.
Contributor
|
All contributors have signed the CLA. ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
An OpenAI group that keeps a failover account for a shared public alias serves a Codex model descriptor with no reasoning levels and text-only input. The client's reasoning-effort slider then has nothing to select and cannot be moved.
Reproduction: one OpenAI group, two accounts, both with an explicit
model_mappingfor the same public alias, pointing at different upstream models.Account B exists because it cannot reach the aliased model natively, so it maps the alias onto the closest model it does have. That is the intended way to keep a standby for an alias, and the Anthropic side is already configured this way in practice.
Served descriptor:
{ "slug": "my-alias", "supported_reasoning_levels": [], "input_modalities": ["text"] }default_reasoning_levelis absent entirely.Cause
Two accounts explicitly mapping one alias to different upstream models makes
codexExplicitModelTargetsConflictForPlatformtrue. With noupstream_model_metadatasnapshot to intersect,groupCodexModelMetadatashort-circuits to{reasoningConflict: true, inputModalitiesConflict: true}.That override empties the level list and forces
input_modalitiesto["text"]. Two details make it unrecoverable downstream:DefaultReasoningLevelis*stringwithomitempty, so nil makes the key absent rather than null.mergeMissingCodexModelFieldsfills only missing-or-null fields, and an empty array counts as present, sosupported_reasoning_levels: []is never repaired.Failing closed is correct when the alias target is genuinely ambiguous. But a group that declares
model_routingfor the alias has already resolved that ambiguity: the operator has stated which accounts serve it, and accountPrioritystates which one leads. Treating that as a conflict rejects a deliberate failover configuration.Change
Manifest side. When a routing rule names the alias, capability declaration is restricted to the routed accounts and the conflict override is skipped. Capabilities then fall back to the same by-name derivation already used for a single account with no metadata snapshot. Behavior is unchanged for groups with no rule, a disabled rule, or a rule naming a different alias.
Scheduling side.
model_routingis stored and looked up platform-agnostically (admin_group.goassigns it with no platform check;Group.GetRoutingAccountIDsis a plain table lookup), but four gates ingateway_scheduling.goonly consulted it for Anthropic. An OpenAI group's rules were therefore accepted, persisted, and shown in the admin UI while never affecting selection.Fixing only the manifest would leave a split brain: the manifest would honor a rule that scheduling ignores. Both sides now share one predicate, and the allowed platform set is defined in exactly one place so adding a platform later is a one-line change.
Selection within a routing list is deliberately untouched. The list is a membership set, and the winner is still decided by
Priority(lower first), then load rate, thenLastUsedAt.Tests
TestCodexAliasFailoverMappingHonorsModelRouting— the routed alias regainslow..maxlevels,mediumdefault, and image input; three negative cases (no rule, rule disabled, rule for another alias) must still fail closed.TestModelRoutingAppliesToPlatform— predicate table including composite groups and non-eligible target platforms.TestGatewayService_SelectAccountForModelWithPlatform_RoutedOpenAIGroup— a routed OpenAI account must win over a higher-priority unrouted one, which fails before this change.Verified with
go build ./...,go vet -tags unit ./internal/service/, andgo test -tags unit ./internal/service/(411 tests matchingCodex|ModelRouting|Routedpass). Five failures in the full package run (TestContentModerationRuntimeSnapshotRefreshFailureKeepsStaleConfig, fourTestPluginPackageInstaller*) reproduce identically on unmodifiedmainand are unrelated to this change.