Skip to content

fix: surface experiment-comparison2 fetch failures and retry transient 5xx - #640

Open
Praneeth Yenugutala (praneethy91) wants to merge 1 commit into
braintrustdata:mainfrom
praneethy91:fix/experiment-summarize-scores-fetch-error
Open

fix: surface experiment-comparison2 fetch failures and retry transient 5xx#640
Praneeth Yenugutala (praneethy91) wants to merge 1 commit into
braintrustdata:mainfrom
praneethy91:fix/experiment-summarize-scores-fetch-error

Conversation

@praneethy91

Copy link
Copy Markdown

Summary

Fixes #639.

Experiment.summarize() caught any exception from the experiment-comparison2 fetch and silently fell back to an empty {} summary, making a transient fetch failure indistinguishable from an experiment that genuinely has no scores. Meanwhile, RetryRequestExceptionsAdapter only retried on connection-level exceptions (timeouts, connection resets), so a request that completed with a non-2xx status (e.g. a 502 from a proxy hiccup) never entered the retry path at all — it went straight to raise_for_status() and got swallowed by summarize().

  • RetryRequestExceptionsAdapter.send() now also retries when a completed response has a transient status code (429/500/502/503/504), using the same exponential backoff as the existing exception-based retry path. This should eliminate most one-off 5xx blips before they ever reach summarize().
  • ExperimentSummary gains a new scores_fetch_error: str | None field, populated whenever the experiment-comparison2 fetch fails after retries are exhausted. scores/metrics still default to {} for backwards compatibility, but callers building automation (e.g. CI gates) on summary.scores can now check scores_fetch_error to tell "fetch failed" apart from "no scores." The printed str(summary) also surfaces a WARNING line when this happens.

Test plan

  • py/src/braintrust/test_http.py::TestRetryOnHttpErrorStatus — new tests covering retry-on-502, giving up after base_num_retries, and not retrying non-retryable statuses (404), using a real local HTTP server (no mocks), consistent with existing adapter tests in this file.
  • py/src/braintrust/test_framework.py::test_experiment_summarize_surfaces_scores_fetch_error — new test asserting summarize() populates scores_fetch_error (and the printed summary contains a WARNING) when the comparison fetch raises.
  • cd py && uv run nox -s test_core — full core suite passes (614 passed, 63 skipped, 12 xfailed).
  • cd py && uv run nox -s pylint — clean.
  • cd py && uv run pre-commit run --files ... on changed files — clean.

…t 5xx

Experiment.summarize() swallowed any exception from the experiment-comparison2
fetch into an empty {} summary, making a transient fetch failure indistinguishable
from an experiment that genuinely has no scores. Separately,
RetryRequestExceptionsAdapter only retried on connection-level exceptions, so a
completed non-2xx response (e.g. a 502 from a proxy hiccup) never entered the
retry path at all.

- RetryRequestExceptionsAdapter now retries responses with a transient status
  (429/500/502/503/504) using the same backoff as connection-level failures.
- ExperimentSummary gains scores_fetch_error, populated when the
  experiment-comparison2 fetch fails, so callers gating automation on
  summary.scores can distinguish "fetch failed" from "no scores".

Fixes braintrustdata#639
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Experiment.summarize() silently discards scores/metrics on any fetch failure instead of surfacing or retrying

2 participants