Skip to content

fix: retry transient failures in jina (TEI) and ollama embedding providers - #125

Merged
GoodbyePlanet merged 1 commit into
mainfrom
fix/embedding-retry-shared
Sep 12, 2026
Merged

GoodbyePlanet merged 1 commit into
mainfrom
fix/embedding-retry-shared

Conversation

@GoodbyePlanet

Copy link
Copy Markdown
Owner

Closes #71.

Problem

server/embeddings/jina.py (self-hosted TEI) and server/embeddings/ollama.py had no retry at all — a single transient 5xx or connection reset aborted the file's embedding. server/indexer/pipeline.py:252-254 catches that, logs, and continues, so the file keeps its stale index entries until a later run.

Meanwhile the 429 backoff + batch loop + malformed-response check was duplicated near-verbatim across voyage.py, openai.py and jina_api.py. None of those retried 5xx or transport errors either — only 429.

Change

New server/embeddings/http_batch.py:

  • post_with_retry() — retries 429 (honouring Retry-After), 5xx, and httpx transport/timeout errors on the shared [10, 20, 30, 40] schedule, then raise_for_status().
  • embed_in_batches() — owns the chunk loop and the vector-count check, parameterized by a per-provider make_body / extract.

All five providers now route through it. Each keeps its own batch size (32 self-hosted, 128 hosted), request shape, and dimension resolution — those are genuinely per-provider. Net −60 lines across the providers.

Tests

  • New tests/embeddings/test_http_batch.py — 12 cases: backoff sequence, Retry-After precedence, 5xx retry + exhaustion, transport-error retry + exhaustion, 4xx not retried, chunking, empty input, length mismatch.
  • Retry and length-mismatch tests added to test_jina.py and test_ollama.py — new coverage, this is the actual fix.
  • The 61 pre-existing provider tests pass unchanged, which is the regression gate on the refactor. Full suite: 362 passed.

🤖 Generated with Claude Code

…iders

The self-hosted jina (TEI) and ollama providers had no retry at all — a
single transient 5xx or connection reset aborted the file's embedding, and
the pipeline then skipped the file, leaving its index entries stale.

Extract the 429 backoff, batch loop and malformed-response check that were
duplicated near-verbatim across voyage, openai and jina_api into a shared
server/embeddings/http_batch.py, and route all five providers through it.
The shared helper also retries 5xx and transport/timeout errors, which no
provider did before.

Closes #71

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@GoodbyePlanet
GoodbyePlanet merged commit 57b4e43 into main Sep 12, 2026
2 checks passed
@GoodbyePlanet
GoodbyePlanet deleted the fix/embedding-retry-shared branch September 12, 2026 11:10
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.

Extract shared retry/batch logic; jina (TEI) and ollama providers have no retry

1 participant