feat: add model fallback chain with error classification and cooldown#92
Closed
Leeaandrob wants to merge 1 commit intosipeed:mainfrom
Closed
feat: add model fallback chain with error classification and cooldown#92Leeaandrob wants to merge 1 commit intosipeed:mainfrom
Leeaandrob wants to merge 1 commit intosipeed:mainfrom
Conversation
Implement a 2-layer model fallback system that automatically retries failed LLM requests across multiple providers/models: - model_ref.go: Parse "provider/model" references with normalization - error_classifier.go: Classify ~40 error patterns into 7 categories (auth, rate_limit, billing, timeout, format, overloaded, unknown) - cooldown.go: Per-provider cooldown with standard backoff (1m→5m→25m→1h) and billing-specific backoff (5h→10h→20h→24h), 24h failure window reset - fallback.go: FallbackChain orchestrator with Execute (text) and ExecuteImage (multimodal), candidate deduplication, context cancellation - types.go: FailoverError, FailoverReason enum, ModelConfig - config.go: model_fallbacks, image_model, image_model_fallbacks fields - loop.go: Integration with AgentLoop when fallback candidates configured Config example: "model": "gpt-4", "model_fallbacks": ["anthropic/claude-opus", "groq/llama-3"], "image_model": "openai/gpt-4o", "image_model_fallbacks": ["anthropic/claude-sonnet"] Backward compatible: without fallbacks configured, behavior is unchanged.
Collaborator
Author
|
Superseded by PR #131 which includes the model-fallback-chain as part of the multi-agent-routing feature branch. |
8 tasks
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
provider/modelformat with provider normalizationmodel_fallbacksconfigured, behavior is unchangedNew Files (8)
model_ref.goprovider/modelreferences with normalizationerror_classifier.gocooldown.gofallback.goExecute()+ExecuteImage()model_ref_test.goerror_classifier_test.gocooldown_test.gofallback_test.goModified Files (3)
types.go: AddFailoverError,FailoverReasonenum,ModelConfigconfig.go: Addmodel_fallbacks,image_model,image_model_fallbacks+ helper methodsloop.go: IntegrateFallbackChainintorunLLMIteration()when candidates > 1Config Example
{ "agents": { "defaults": { "model": "gpt-4", "model_fallbacks": ["anthropic/claude-opus", "groq/llama-3"], "image_model": "openai/gpt-4o", "image_model_fallbacks": ["anthropic/claude-sonnet"] } } }Cooldown Behavior
Test plan
go build ./...passesgo vet ./...passes