feat: add default downgrade chains for OpenAI and Gemini#5
Merged
Conversation
- OpenAI chain: gpt-4o → gpt-4.1 → gpt-4o-mini → gpt-4.1-mini - Anthropic chain: claude-opus-4-6 → claude-sonnet-4-6 → claude-haiku-4-5 - Google chain: gemini-2.5-pro → gemini-2.5-flash - Auto-select chain based on provider when no explicit chain configured - Remove explicit-chain guard from shouldDowngradeForThreshold so builtin chains also work for threshold-based downgrade
- Remove gate.default_downgrade_chain and gate.agents[].downgrade_chain
required-when-downgrade validations — builtin provider chains now cover
OpenAI/Anthropic/Google without explicit config
- Update test-downgrade.sh with 4 cases:
1. Explicit chain overrides builtin (gpt-4o → gpt-4o-mini)
2. Builtin OpenAI chain auto-selected (gpt-4o → gpt-4.1)
3. Builtin Anthropic chain auto-selected (claude-opus-4-6 → claude-sonnet-4-6)
4. Last model in chain — no downgrade (gpt-4.1-mini)
- Add second mock Anthropic upstream and allow_reuse_address to both mocks
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
Implements built-in provider downgrade chains that auto-select based on the model being used, with no explicit configuration required.
Changes
internal/budget/chains.go— built-in chains for OpenAI, Anthropic, Google;builtinChainForModel()detects provider by model name prefixRewriteModelForDowngrade— falls back to built-in chain when no explicit chain configuredshouldDowngradeForThreshold— removes chain-existence guard so threshold-based downgrade works with built-in chainsinternal/budget/chains_test.go— 17 sub-tests covering all providers, unknown models, explicit chain override, case-insensitive matchingBuilt-in chains:
Testing
Checklist