Skip to content

Retry timeout before model cascade fallback - #60

Merged
morgaesis merged 3 commits into
mainfrom
feat/retry-before-fallback
Jul 12, 2026
Merged

Retry timeout before model cascade fallback#60
morgaesis merged 3 commits into
mainfrom
feat/retry-before-fallback

Conversation

@morgaesis

Copy link
Copy Markdown
Contributor

OpenRouter and other providers can experience transient slowness where a request is legitimately processing but takes longer than our individual request timeout. Rather than immediately falling back to a weaker model, retry the same model once more (with backoff) before giving up.

Timeout retries are separate from transient-error retries (connection errors, retryable HTTP statuses) which already had retry-with-backoff logic. The implementation keeps reviews inside the worker watchdog by setting the request timeout to 240s with up to one 90s retry, and capping the entire review model phase at 420s total.

This addresses the issue where deepseek-v4-pro was only serving ~8% of reviews due to unnecessary fallbacks when the model was actually responding but slowly. Testing confirms successful retry after timeout, proper fallback when retries exhaust, and total budget enforcement.

OpenRouter and other providers can experience transient slowness where a
request is legitimately processing but takes longer than our individual
request timeout. Rather than immediately falling back to a weaker model,
retry the same model once more (with backoff) before giving up.

Timeout retries are separate from transient-error retries (connection
errors, retryable HTTP statuses) which already had retry-with-backoff
logic. The timeout retry is scoped to keep reviews inside the worker
watchdog: request timeout is 240s with up to one 90s retry attempt,
and the entire review model phase is capped at 420s.

This reduces unnecessary model fallbacks from <10% successful primary
model usage to a much higher rate, while maintaining deterministic
timeouts and respecting the shared total LLM budget.

Tests cover: successful retry after timeout, exhausted retries leading
to fallback, and total budget enforcement.
Allow the 8-argument signature for chat_with_temperature and chat_inner
since the parameters are all necessary for the transport and retry logic.

@postil-dev postil-dev 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.

Gate: failed

The diff introduces timeout retry logic for LLM requests, but the README.md update does not match the new timeout values in the code.

  • error Update README to reflect new timeout values · severity: error · confidence 0.25 · kind: uncertainty
Review metadata
  • Model: mistralai/mistral-small-3.2-24b-instruct
  • Review duration: 181.53 s
  • Commit: 56bab76
  • Dashboard run: View in Postil
  • Tokens: 29797 prompt, 16813 completion
  • Scorer: anthropic/claude-haiku-4.5 (1 disagreement(s))

Comment thread README.md Outdated
Expand the timeout documentation to explain that the timeout retry
feature specifically reduces unnecessary fallback to weaker models when
the primary model is slow but working. Include explicit mention of retry
behavior at the same model level before cascade.
@morgaesis
morgaesis merged commit f19a189 into main Jul 12, 2026
9 checks passed
@morgaesis morgaesis mentioned this pull request Jul 12, 2026
morgaesis added a commit that referenced this pull request Jul 12, 2026
Releases timeout-retry-before-cascade-fallback from #60.
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.

1 participant