Repository navigation
fix(embeddings): defer operations when OpenAI embeddings run out of credits - #5746
Merged
Merged
Conversation
…client a timeout and the configured retries Closes #5588
…he model in the factory test - configuration.mdx (+ regenerated docs skill): HINDSIGHT_API_EMBEDDINGS_MAX_RETRIES no longer says the openai family ignores it; it names the four providers that take it and the insufficient_quota 15-minute defer. - test_client_carries_timeout_and_configured_retries: set the OpenAI embeddings model and clear the base URL, so a developer env with a different model can't make initialize() probe the real API.
audichuang
added a commit
to audichuang/hindsight
that referenced
this pull request
Oct 20, 2026
fix(embeddings): backport vectorize-io#5746 — OpenAI-family embeddings honour EMBEDDINGS_MAX_RETRIES, get a timeout, defer on insufficient_quota
Merged
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5588.
Problem
insufficient_quotawas retried 3 × 60s, then the operation was markedfailedfor good. Nothing picked it up again once credits came back.generate_embeddings_batchre-wrapped every error in a plainExceptionwithoutfrom e, so the original error was lost.timeout. The SDK default is 600s per attempt, so one stalled request could hold a retain for ~40 minutes.HINDSIGHT_API_EMBEDDINGS_MAX_RETRIESto the OpenAI-family providers, so that setting did nothing there.Fix
OpenAIEmbeddings._embed_batchturns a 429insufficient_quotaintoProviderRateLimitResetError, retrying in 15 minutes. The worker already turns that error into aDeferOperation, the same path the LLM providers use, so the retry count is not used up. Other 429s behave as before.generate_embeddings_batchlets that error through unchanged and keeps the cause (from e) on all other errors.openai,openai-codex,openrouterandrequestynow getmax_retriesfromHINDSIGHT_API_EMBEDDINGS_MAX_RETRIES.I kept the 15-minute wait as a fixed value, not a new env var like the reference branch has. A new setting can be added if someone needs to tune it.
Tests
tests/test_embeddings_openai_quota.py: aninsufficient_quotaerror defers throughgenerate_embeddings_batch; an ordinary 429 still fails and keeps its cause; the client built by the factory has the timeout and the configured retry count.Thanks to @choi138 for the detailed report and reference branch.