Skip to content

fix(batch-evaluation): use a 60 s timeout for observation page fetches - #2096

Merged
hassiebp merged 1 commit into
langfuse:mainfrom
DavidTraina:fix/batch-eval-observation-fetch-timeout
Nov 5, 2026
Merged

hassiebp merged 1 commit into
langfuse:mainfrom
DavidTraina:fix/batch-eval-observation-fetch-timeout

Conversation

@DavidTraina

@DavidTraina DavidTraina commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Since langfuse/langfuse#19043, the observations v2 API keeps scanning until it fills the page or reaches its 45 s budget, so slow pages are expected. This is especially true for selective filters on large projects. Batch evaluation fetched pages with the client-wide timeout, which defaults to 5 s.

Fern retries only 408/409/429/5xx responses, not httpx timeouts. So the run stopped on the first slow page with completed=False. Resuming sent the identical request and timed out the same way, so the run never made progress. The error log also said Failed to fetch batch after 3 retries after a single attempt.

Fix

  • Send timeout_in_seconds=60 per request on observation page fetches.
  • Leave the global timeout alone. Raising LANGFUSE_TIMEOUT would also lengthen the OTLP export deadline, and with it flush() and shutdown() when the host is unreachable.
  • Log Failed to fetch batch: <error> without the misleading retry count.

The per-request option also applies when the user passes a custom httpx_client.

Related PRs

Independent follow-ups to langfuse/langfuse#19043, mergeable in any order: #2097 (batch evaluation stops on empty pages), #2098 (docs), #2099 (test helpers), #2101 (pagination helper).

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Documentation update
  • Tooling, CI, or repo maintenance

Verification

List the main commands you ran:

uv run --frozen ruff check .                                  # All checks passed!
uv run --frozen ruff format --check .                         # 593 files already formatted
uv run --frozen mypy langfuse --no-error-summary              # no issues
uv run --frozen pytest -n auto --dist worksteal tests/unit    # 1003 passed, 2 skipped

I also ran run_batched_evaluation against a local stub server that answers after 7 s. Before the change it failed after 5.0 s with one request (completed=False). With timeout_in_seconds=60 the same call succeeded after 7.0 s.

Checklist

  • I self-reviewed the diff using code_review.md.
  • I added or updated tests for behavior changes.
  • I updated docs, examples, or .env.template if needed.
  • I did not hand-edit generated files; if generated files changed, I used the upstream regeneration path.
  • I did not commit secrets or credentials.

RetriggerView in GreptileConfidence Score: 5/5

This PR appears safe to merge.

Summary

Batch evaluation now gives each observation page request a 60-second timeout without changing the client-wide timeout.

  • Batch evaluation waits up to 60 seconds for each observation page.
  • Batch evaluation logs fetch failures without a retry count.

Reviews (1) · Last reviewed commit: "fix(batch-evaluation): use a 60 s timeou..." · Reviewed by Greptile

The observations v2 API can scan for up to 45 s before returning a page,
but page fetches used the client-wide default timeout of 5 s. Timeouts are
not retried, so the run stopped, and resuming repeated the same request.
Send a per-request timeout above the server budget without changing the
global timeout, and drop the 'after N retries' wording from the fetch
failure log, since timeouts and 422s are never retried.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@hassiebp
hassiebp merged commit 9e760d6 into langfuse:main Nov 5, 2026
26 checks passed
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.

2 participants