fix(runtime): retry transient mid-stream provider errors instead of crashing the scan#891
Merged
Merged
Conversation
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
Greptile SummaryAdds bounded turn-level recovery for transient model-provider failures.
Confidence Score: 5/5The PR appears safe to merge with no actionable defects identified. The retry path is bounded, preserves existing handling for rate limits and permanent failures, and propagates sustained transient failures after exhaustion. Important Files Changed
Reviews (1): Last reviewed commit: "fix(runtime): retry transient mid-stream..." | Re-trigger Greptile |
0xallam
approved these changes
Jul 26, 2026
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
A transient upstream provider error raised mid-stream currently propagates out of
_run_cycleand kills the entire scan (in non-interactive modeif not interactive: raise), tearing down every live agent.The most common shape is a bare
openai.APIErrorwith no status code: after the HTTP request has already returned 200 and tokens have started streaming, the server injects an{"error": ...}frame into the SSE stream and the OpenAI SDK raisesAPIError("An error occurred while processing the request."). The agents SDK's own retry can't replay this — once tokens have streamed it treats the turn as retry-unsafe — so it re-raises and the whole run dies.This adds a bounded, turn-level retry in
_run_cyclefor transient model/provider errors, sitting alongside the existing image-strip and context-overflow recovery branches:Classification (
_is_transient_model_error):APIConnectionError,APITimeoutError)APIStatusErrorwith 408 / 500 / 502 / 503 / 504APIError(no status code) — the mid-stream caseRateLimitError(429)runner.run_strix_scanValueError, etc.)After
_MAX_TRANSIENT_MODEL_RETRIES(4) exhausted attempts the error propagates as before, so a genuine sustained outage still fails the scan rather than looping forever.Replaying with
input_data = []when a session is present is correct because the turn's input is persisted to the session before the model streams (in the SDK's streamed run loop), so re-running the turn reads it back from session state rather than duplicating it — the same pattern the existing image-strip / compaction recovery already relies on.Tests
New
tests/test_execution_transient_retry.py:APIError, network errors, 5xx, rate limit exclusion, permanent 4xx, non-provider errors);_run_cyclereplays a mid-streamAPIErrorand succeeds on the next attempt;_run_cyclegives up and propagates after the retry bound;_run_cycledoes not retry a permanent client error.Link to Devin session: https://app.devin.ai/sessions/dad023e379e942f287bcf6822463b7a4
Requested by: @0xallam