refactor(ai-adapters): keep provider failures typed through retry logic#560
Draft
cooleryu wants to merge 1 commit intoGCWing:mainfrom
Draft
refactor(ai-adapters): keep provider failures typed through retry logic#560cooleryu wants to merge 1 commit intoGCWing:mainfrom
cooleryu wants to merge 1 commit intoGCWing:mainfrom
Conversation
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
This keeps provider failures structured from the adapter layer through the core retry/error-detail path.
The PR adds a small
ProviderError/ProviderErrorKindmodel inbitfun-ai-adapters, parses provider error payloads from HTTP and streaming responses, and preserves those details asBitFunError::AIProviderinstead of flattening them into strings too early.Motivation
Provider errors currently reach the UI through
ErrorCategory/AiErrorDetail, but the adapter boundary can turn them into plain strings first. That makes useful details like provider code, request id, HTTP status, and retryability depend on downstream string matching.Keeping the error typed at the provider boundary gives retry logic and diagnostics a stable signal, while keeping the existing string-based fallback path for older or unknown adapter errors.
Changes
ProviderErrorandProviderErrorKindinbitfun-ai-adapters.messageerror eventsBitFunError::AIProviderand direct mapping toErrorCategory/AiErrorDetail.1305, HTTP error bodies, structured quota errors, and retry decisions.Test Plan
LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $HOME/.cargo/bin/cargo test -p bitfun-ai-adapters --libLC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $HOME/.cargo/bin/cargo test -p bitfun-core structured_provider --libLC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $HOME/.cargo/bin/cargo test -p bitfun-core agentic::execution::round_executor::tests --lib/Users/behappy/.cargo/bin/cargo test -p bitfun-core --test stream_processor_openai/Users/behappy/.cargo/bin/rustfmt --edition 2021 --check <touched Rust files>git diff --checkNotes
I kept this intentionally bounded to the adapter/core error boundary. The existing
AIClient(String)classification stays in place as a fallback, so this should not require a broader error-policy migration or a UI change.