Skip to content

fix(ollama): wrap timeout/connection errors so they retry#829

Open
dev-ploy wants to merge 2 commits into
repowise-dev:mainfrom
dev-ploy:fix/page_generation
Open

fix(ollama): wrap timeout/connection errors so they retry#829
dev-ploy wants to merge 2 commits into
repowise-dev:mainfrom
dev-ploy:fix/page_generation

Conversation

@dev-ploy

@dev-ploy dev-ploy commented Jul 14, 2026

Copy link
Copy Markdown

Summary

  • Fix page_generation_failed floods with local LLMs (Ollama): APITimeoutError
    and APIConnectionError are siblings of APIStatusError under
    openai.APIError, so the old catch-only-APIStatusError clause let them escape
    uncaught, skipping the tenacity retry loop entirely and surfacing as
    page_generation_failed in orchestrate.py (run_levelguarded_named).
  • Move the Ollama provider onto the shared retry policy
    (provider_should_retry / provider_retry_stop / provider_retry_wait) with a
    3-way exception mapping (RateLimitError → 429, APIStatusError → HTTP status,
    APIError → transient) so transient timeout/connection errors retry while
    non-retryable 4xx (400/401/403/404/405/413/422) fail fast. Same wrapping applied
    to both stream_chat sites.
  • Apply the same defensive APIError catch 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

  • Tests pass (pytest) — 897 provider + CLI tests green
  • Lint passes (ruff check) on all changed files
  • Web build passes (npm run build) — N/A, no frontend changes

Additional manual verification against a live Ollama server, across multiple
locally running models:

  • Full repowise init --provider ollama --concurrency 6 --coverage 0.5 runs
    against several local models → all pages generated with 0
    page_generation_failed
    , and the local-provider concurrency warning shown.
  • Forced a real APITimeoutError (1 ms client timeout against the live server):
    now wrapped as ProviderError and retried 3× instead of escaping raw.
  • New regression tests confirm 401 (auth) and 400 (invalid request) fail on the
    first attempt — no wasted retries.

Checklist

  • My code follows the project's code style
  • I have added tests for new functionality
  • All existing tests still pass
  • I have updated documentation if needed

@repowise-bot

repowise-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

✅ Health: 7.6 (unchanged)

📋 At a glance
1 file changed health · 5 hotspots touched · 6 new findings introduced · 5 co-change pairs left out · 3 files with recent fix history. Scoped to packages.

⚠️ Change risk: moderate (riskier than 52% of this repo's commits · raw 9.0/10)
This change's risk is driven by:

  • more lines added than baseline
  • more scattered than baseline

🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)

File Score Δ Why
.../init_cmd/command.py 2.7 → 2.8 ▲ +0.2 ✅ resolved function hotspot, complex method, dry violation
🔎 More signals (2)

🔥 Hotspots touched (5)

  • .../init_cmd/command.py — 19 commits/90d, 1 dependents · primary owner: Raghav Chamadiya (93%)
  • .../llm/deepseek.py — 6 commits/90d, 3 dependents · primary owner: ecourn (59%)
  • .../llm/ollama.py — 4 commits/90d, 5 dependents · primary owner: Raghav Chamadiya (93%)
2 more
  • .../llm/openrouter.py — 5 commits/90d, 8 dependents · primary owner: lenya lozhkin (55%)
  • .../llm/openai.py — 6 commits/90d, 8 dependents · primary owner: Raghav Chamadiya (87%)

🔗 Hidden coupling (2 files)

  • .../init_cmd/command.py co-changes with these files (not in this PR):
    • docs/CLI_REFERENCE.md (9× — 🟢 routine)
    • .../init_cmd/workspace.py (7× — 🟢 routine)
    • docs/USER_GUIDE.md (5× — 🟢 routine)
    • .../cli/helpers.py (5× — 🟢 routine)
  • .../llm/openai.py co-changes with .../llm/anthropic.py (6× — 🟢 routine) — not in this PR.

👀 Suggested reviewers @ecourn


📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-14 16:01 UTC
Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot

Parametrize the three test_generate_wraps_* cases over a shared helper to
resolve the DRY violation flagged in review.
@dev-ploy

dev-ploy commented Jul 15, 2026

Copy link
Copy Markdown
Author

Hi @RaghavChamadiya i would love your view on this solution

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.

[Bug] many page_generation_failed errors when running wiki init

1 participant