Repository navigation
fix(provider): surface the HTTP error body, Retry-After and code-only transient classification - #490
Merged
Merged
Conversation
… transient classification
…-body # Conflicts: # CHANGELOG.md
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What (description of the change)
The chat-completions request now uses a dedicated agent built with
http_status_as_error(false), so a 4xx/5xx arrives as a response andcomplete()'s existing non-2xx branch can read the body. The error line becomeshttp status: 400 Bad Request — <scrubbed 200-char snippet>, with(retry-after: N)inserted after the reason when the header is present.build_agent(the/modelsprobes) is untouched, sofetch_model_ids_with_timeoutandfetch_context_windowkeep theirErr-on-non-2xx behavior, now pinned by explicit tests.is_transient_provider_errorispub(crate)so the new equivalence tests can call it. CHANGELOG entry under [Unreleased].Why (the problem you're solving)
Closes #474. ureq 3 defaults to
http_status_as_error(true), so a 4xx/5xx came back asErr(StatusCode(code))carrying only the code: quota exhausted, rate-limit detail, invalid model, context overflow and billing failures were all invisible to the operator (http status: 400, nothing else). The same defect class was already fixed in the gitea (#233) and systemone (#328) clients.Testing (how you verified this works)
http status: 400/429/500with no body and no Retry-After. The 6th (fetch_* pinning) passed before and after, as intended.http_error_testscover a 400 JSON body (streaming and non-streaming, exact text), a 429 withRetry-After(stays transient + failover), a 503 HTML body (API key scrubbed, snippet exactly 200 chars), an unreadable body (… — <unreadable body>), the 400/422/401 body-text cases that must NOT become transient (classification equivalence with and without the body, per the issue's Classification section — the code-only rule itself already landed with fix(core): classify provider http-status errors by code, not by substring #486, so no classification code was added), andfetch_model_ids/fetch_context_windowunchanged on 401/404.tole: provider failed: http status: 400 Bad Request — {"error": {"message": "This model's maximum context length is 131072 tokens. However, your messages resulted in 142900 tokens.", "code": "context_length_exceeded"}} (resume with: …), rc 4.cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace --no-fail-fast(907 passed / 0 failed),cargo test -p tole-core --no-default-features(339 passed / 0 failed),cargo build -p tole-cli --no-default-features: all pass. One flaky timing test (perf_threshold::single_turn_tool_chain_under_budget) failed once under parallel load and passed alone and in the clean full re-run; it was not changed.cora review --stagedat commit time: "No issues found".