fix(ollama): wrap timeout/connection errors so they retry#829
Conversation
|
✅ Health: 7.6 (unchanged) 📋 At a glance
🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)
🔎 More signals (2)🔥 Hotspots touched (5)
2 more
🔗 Hidden coupling (2 files)
👀 Suggested reviewers @ecourn 📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-14 16:01 UTC |
Parametrize the three test_generate_wraps_* cases over a shared helper to resolve the DRY violation flagged in review.
|
Hi @RaghavChamadiya i would love your view on this solution |
RaghavChamadiya
left a comment
There was a problem hiding this comment.
Really solid fix, thanks, and it held up well despite sitting for a bit. I confirmed the bug is still live on main: Ollama still catches only APIStatusError, so APITimeoutError and APIConnectionError keep escaping tenacity and surfacing as page_generation_failed. The root-cause framing is spot on, and moving Ollama onto the shared provider_should_retry / provider_retry_stop / provider_retry_wait policy is exactly right, it lines up with what the openai provider already does.
I pulled the branch: it still merges cleanly, the full provider suite is green (166 passing), and the new regression tests pin the important parts, both that timeout/connection errors now retry and that non-retryable 4xx still fail fast. Appreciate the manual verification against a live Ollama server too.
Merging.
Summary
page_generation_failedfloods with local LLMs (Ollama):APITimeoutErrorand
APIConnectionErrorare siblings ofAPIStatusErrorunderopenai.APIError, so the old catch-only-APIStatusErrorclause let them escapeuncaught, skipping the tenacity retry loop entirely and surfacing as
page_generation_failedinorchestrate.py(run_level→guarded_named).(
provider_should_retry/provider_retry_stop/provider_retry_wait) with a3-way exception mapping (
RateLimitError→ 429,APIStatusError→ HTTP status,APIError→ transient) so transient timeout/connection errors retry whilenon-retryable 4xx (400/401/403/404/405/413/422) fail fast. Same wrapping applied
to both
stream_chatsites.APIErrorcatch to the other OpenAI-client providers(
openai,openrouter,deepseek), and warn when a local provider(
ollama/codex_cli/opencode) runs with--concurrency > 4.Related Issues
Closes #445
Test Plan
pytest) — 897 provider + CLI tests greenruff check) on all changed filesnpm run build) — N/A, no frontend changesAdditional manual verification against a live Ollama server, across multiple
locally running models:
repowise init --provider ollama --concurrency 6 --coverage 0.5runsagainst several local models → all pages generated with 0
page_generation_failed, and the local-provider concurrency warning shown.APITimeoutError(1 ms client timeout against the live server):now wrapped as
ProviderErrorand retried 3× instead of escaping raw.first attempt — no wasted retries.
Checklist