fix(provider): correct model_not_found misclassification and unify re…#2141
Open
xiang33 wants to merge 1 commit intosipeed:mainfrom
Open
fix(provider): correct model_not_found misclassification and unify re…#2141xiang33 wants to merge 1 commit intosipeed:mainfrom
xiang33 wants to merge 1 commit intosipeed:mainfrom
Conversation
…try error handling - error_classifier: add modelNotFoundPatterns with highest priority in classifyByMessage(); for transient HTTP statuses (5xx), override with message-level classification when body indicates a concrete non-transient error (e.g. zhipu 503 + model_not_found → FailoverFormat, not timeout) - loop: replace ad-hoc string matching in retry loop with errors.As() to extract typed FailoverReason from FallbackChain, preserving string matching as backward-compat fallback for single-candidate path - fallback: add Unwrap() to FallbackExhaustedError so errors.As() can traverse into the underlying FailoverError
Collaborator
|
plz fix Linter |
|
@xiang33 Hi! This PR has been inactive for over a week. If there's no update in the next 7 days, it will be closed automatically. If you're still working on it, just leave a comment to keep it open! |
|
|
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.
…try error handling
📝 Description
Fix two issues in the provider error classification and agent retry logic:
model_not_foundmisclassified as timeout: When providers (e.g. zhipu) return HTTP 503 withmodel_not_foundin the response body,ClassifyError()only checked theHTTP status code (503 → transient timeout) and skipped message-level classification. This caused a non-retriable configuration error to enter cooldown and trigger unnecessary
retry loops.
Inconsistent retry error classification: The outer retry loop in
loop.goused ad-hoc string matching to classify errors, whileFallbackChainalready performed typedclassification via
ClassifyError(). This architectural inconsistency was fragile and could lead to incorrect retry decisions when error message formats change.🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
📚 Technical Context (Skip for Docs)
error_classifier.go: AddedmodelNotFoundPatternswith highest priority inclassifyByMessage(). For transient HTTP statuses (5xx), message-level classification nowoverrides status-level when body indicates a concrete non-transient error (e.g.
503 + model_not_found → FailoverFormat).loop.go: Replaced ad-hoc string matching in retry loop witherrors.As()to extract typedFailoverReasonfromFallbackChain. String matching preserved asbackward-compat fallback for single-candidate path.
fallback.go: AddedUnwrap()toFallbackExhaustedErrorsoerrors.As()can traverse into the underlyingFailoverError.🧪 Test Environment
📸 Evidence (Optional)
Click to view Logs/Screenshots
All existing tests pass:
ok github.com/sipeed/picoclaw/pkg/providers
ok github.com/sipeed/picoclaw/pkg/providers/anthropic
ok github.com/sipeed/picoclaw/pkg/providers/anthropic_messages
ok github.com/sipeed/picoclaw/pkg/providers/azure
ok github.com/sipeed/picoclaw/pkg/providers/bedrock
ok github.com/sipeed/picoclaw/pkg/providers/common
ok github.com/sipeed/picoclaw/pkg/providers/openai_compat
ok github.com/sipeed/picoclaw/pkg/providers/openai_responses_common
ok github.com/sipeed/picoclaw/pkg/agent
☑️ Checklist