Skip to content

feat(reranker): per-provider HTTP timeout env vars#1810

Merged
nicoloboschi merged 1 commit into
mainfrom
feat/configurable-reranker-timeout
May 28, 2026
Merged

feat(reranker): per-provider HTTP timeout env vars#1810
nicoloboschi merged 1 commit into
mainfrom
feat/configurable-reranker-timeout

Conversation

@nicoloboschi
Copy link
Copy Markdown
Collaborator

Summary

Closes #1807.

Every HTTP-based reranker provider in cross_encoder.py (cohere, openrouter, zeroentropy, siliconflow, alibaba, litellm proxy/SDK, google) had a hardcoded 60.0s timeout on its httpx.AsyncClient / Cohere SDK / litellm.arerank call. The reporter was patching the source via a Docker volume mount to lift it; this PR exposes the knob properly.

  • Added one env var per provider: HINDSIGHT_API_RERANKER_<PROVIDER>_TIMEOUT (defaults to 60.0 so unset envs keep current behavior).
  • Wired each value through HindsightConfig.from_env() into create_cross_encoder_from_env().
  • TEI was already configurable via HINDSIGHT_API_RERANKER_TEI_HTTP_TIMEOUT — unchanged.
  • Documented the new vars in hindsight-docs/docs/developer/configuration.md.

Test plan

  • uv run pytest tests/test_reranker_timeouts.py — new parametrized test asserts each provider's instance (or its inner HTTP client) ends up with the configured timeout; a second test asserts unset envs still yield 60.0.
  • uv run pytest tests/test_cohere_cross_encoder.py tests/test_google_cross_encoder.py tests/test_litellm_sdk_cross_encoder.py tests/test_tei_cross_encoder.py tests/test_reranker_error_handling.py tests/test_reranker_score_normalization.py — 76 passed, 6 skipped, no regressions.
  • ./scripts/hooks/lint.sh — all lints pass.
  • uv run ty check hindsight_api/ — clean.

Closes #1807. The HTTP-based rerankers (cohere, openrouter, zeroentropy,
siliconflow, alibaba, litellm proxy/SDK, google) all hardcoded a 60s
timeout, forcing users with slower self-hosted models or large batches
to patch the source. Each provider now reads its own
HINDSIGHT_API_RERANKER_<PROVIDER>_TIMEOUT env var (default 60.0s, so
unset envs keep current behavior). TEI already had its own knob.
@nicoloboschi nicoloboschi merged commit a510b07 into main May 28, 2026
70 of 71 checks passed
r266-tech added a commit to r266-tech/hindsight that referenced this pull request May 28, 2026
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.

Add configurable timeout for HTTP-based cross-encoder/reranker

1 participant