Skip to content

fix(proxy): dynamic pro model fallback with account-aware remapping - #2286

Merged
lbjlaq merged 1 commit into
lbjlaq:mainfrom
Oldcircle:pr/dynamic-remap-fallback
Mar 12, 2026
Merged

lbjlaq merged 1 commit into
lbjlaq:mainfrom
Oldcircle:pr/dynamic-remap-fallback

Conversation

@Oldcircle

Copy link
Copy Markdown
Contributor

Summary

This PR adds account-aware dynamic model remapping with fallback support for Gemini Pro model variants.

Changes

  • token_manager.rs: Add resolve_dynamic_model_for_account() method that detects when an account lacks access to a specific Pro tier (high/low) and automatically falls back to the available tier or preview endpoint
  • model_mapping.rs: Add explicit pass-through mappings for Gemini 3.x Pro variants (low/high/preview), with generic aliases routing to the preview entrypoint
  • handlers/openai.rs & handlers/gemini.rs: Call resolve_dynamic_model_for_account after account selection to apply per-account model remapping
  • mappers/common_utils.rs: Minor adjustment to apply_dynamic_model_remapping for consistency
  • docs/model-remapping-logic.md: Add documentation explaining the remapping priority chain

Problem Solved

When users have multiple accounts with different Gemini Pro tier access levels (some with gemini-3.1-pro-high, some with gemini-3.1-pro-low), the proxy would route requests to the wrong tier or fail with 404/400 errors. This PR introduces account-aware fallback logic so the proxy automatically selects the best available model tier for each account.

Remapping Priority Chain

1. Dynamic API deprecation rules (DYNAMIC_MODEL_FORWARDING_RULES)
2. Account-specific capability check → fallback to available tier
3. User custom mapping (custom_mapping)
4. System default mapping (CLAUDE_TO_GEMINI)
5. Pass-through for unknown model IDs

Test plan

  • Verify that accounts with only gemini-3.1-pro-high access correctly handle requests for gemini-3.1-pro-low
  • Verify that pass-through still works for unknown model IDs
  • Verify that gemini-3-pro / gemini-3.1-pro (generic aliases) correctly route to *-preview
  • Verify that gemini-3-pro-high / gemini-3-pro-low (concrete IDs) pass through unchanged
  • Run cargo test for the proxy module

🤖 Generated with Claude Code

@lbjlaq
lbjlaq merged commit 205d8e3 into lbjlaq:main Mar 12, 2026
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.

2 participants