← Back to Pull requests

Retry transient failures while polling OpenAI background responses #4900

Closed
unknown closed this pull request without merging on Aug 31, 2026 19:36 UTC
View on GitHub
unknown unknown commented on Aug 15, 2026 22:19 UTC
Author

This PR contains:


  • New features

  • Changes to dev-tools e.g. CI config / github tooling

  • Docs

  • Bug fixes

  • Code refactor
  • What is the current behavior? (You can also link to an open issue here)

    When the Responses API runs in background mode, client.responses.retrieve() wraps transport failures as OpenAI SDK exceptions such as APIConnectionError and APITimeoutError. The polling retry predicate only recognized raw HTTPX exceptions, so a transient failure aborted polling instead of retrying the already-running response.

    Fixes #4880.

    What is the new behavior?

    Background polling retries APIConnectionError (including APITimeoutError) with the existing five-attempt/60-second bound. It does not retry status errors such as rate limits. The exhausted path re-raises the original SDK exception, and regression coverage exercises both a successful retry and five-attempt exhaustion under asyncio and Trio.

    Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

    No.

    Validation after merging current main:

  • python -m pytest tests/model/providers/test_openai_responses.py -q: 64 passed, 16 skipped (live API and Trio-only variants)

  • Targeted retry tests with --runtrio: 2 passed, 2 asyncio variants skipped, 76 deselected

  • Ruff lint and format checks passed for all three touched Python files

  • Mypy passed for src/inspect_ai/model/_providers/openai_responses.py

  • git diff --check passed
  • Agent review


  • Reviewer: OpenAI Codex (fresh delegated context), one post-implementation pass

  • Findings: 2 fixed — merging current main had moved the CHANGELOG entry into released version 0.3.260, and the PR body still described the superseded shared-classifier implementation; no remaining findings in the touched files
  • Diff: 230 lines (+172 / -58) across 2 files Reviewer: jacobbabula Review duration: 22876m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 230 lines diff across 2 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.326
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #4900"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42% (MEDIUM) · Higher = larger blast radius
    42%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.6% · Safe to merge
    16.6%