Repository navigation
fix(openai): keep embedding batch waits within timeout - #111675
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 6:05 PM ET / 22:05 UTC. ClawSweeper reviewWhat this changesThe PR makes OpenAI embedding-batch status requests, pending polls, and retry backoff waits share one configured operation timeout and adds regression coverage for both wait paths. Merge readinessKeep this PR open: current main contains the matching timeout repair for Voyage batches, not OpenAI batches, so this remains the needed OpenAI counterpart. The patch uses the existing shared provider-deadline contract, has strong exact-head transport proof, and has no actionable correctness finding; wait for the in-progress exact-head build and lint checks before maintainer landing. Priority: P2 Review scores
Verification
How this fits togetherThe OpenAI plugin uploads embedding input, creates a remote batch, then polls its status before downloading output. This PR changes the polling stage so requests and waits cannot extend past the timeout supplied by the embedding caller. flowchart LR
A[Embedding request] --> B[OpenAI batch upload and creation]
B --> C[Batch status polling]
C --> D{Pending or retryable error?}
D --> E[Shared operation deadline]
E --> F[Bounded wait or abortable request]
F --> G[Embedding output or timeout error]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +21, Tests +98. Total +119 across 2 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the OpenAI owner-level repair after the current-head checks complete successfully, keeping the shared provider deadline as the sole timeout mechanism and preserving the retry failure as the timeout cause. Do we have a high-confidence way to reproduce the issue? Yes: the maintainer’s exact-head real-transport comparison exercises the OpenAI batch owner through upload, status polling, retryable HTTP 503, abort, and output download. Current main differs from that tested base only in the sibling Voyage batch files, so the OpenAI reproduction path remains applicable. Is this the best way to solve the issue? Yes: the patch fixes the timeout at the OpenAI polling owner by reusing the existing provider operation deadline and guarded HTTP cancellation contract, rather than adding a local timer or downstream workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9a3db656381d. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
46a9e8b to
df7d68a
Compare
|
Maintainer verification on exact rebased head
No production follow-up, dependency, config, changelog, or unrelated edits. |
|
Merged via squash.
|
* fix(openai): keep embedding batch waits within timeout * test(openai): isolate batch poll timers from provider body guards --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes an issue where users waiting for OpenAI embedding batches could exceed the configured total timeout in either the normal pending-status path or the retryable status-error backoff path.
Why This Change Was Made
Both waiter branches now share one provider operation deadline across backoff sleeps and status-request aborts while preserving the retry error as the timeout cause. Risk note: retry timing is user-visible for transient provider failures, so both pending and retry branches are covered through expiration.
User Impact
OpenAI remote embedding batch waits now stop within the configured total budget, including after transient status errors.
Evidence
I drove the real exported
runOpenAiEmbeddingBatches()and real provider deadline/backoff code. A temporary loader replaced only upload/HTTP transport seams; the timer and status loop remained production code. The same harness against the pre-fix source showed the pending wait at 1000 ms and retry waits at[500,1000]; the fixed source clamps both remaining waits to 500 ms:The regression cases keep each operation pending through expiration, verify no extra status request is sent, and retain the original retry failure as the timeout cause.
Live OpenAI credentials were not available; the proof exercises the deadline and retry behavior before provider-specific output processing.
AI-assisted: Codex helped implement and review the change; the behavior proof and validation above were run manually.
Maintainer real-transport verification (rebased head
df7d68ae08f1183ba3d2f724e348bcb36b0fadae)Ran the unchanged production OpenAI embedding owner plus actual shared SSRF-guarded HTTP transport against a real localhost provider. Every request used an isolated synthetic bearer credential; multipart uploads, batch creation, status replies, real HTTP 503 errors, output downloads, abort signals, TCP socket cleanup, wall-clock timers, and retry loops were real—not mocked.
Focused changed-surface proof:
OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-vitest-s02-111675-openai-repaired node scripts/run-vitest.mjs extensions/openai/embedding-batch.test.ts— 11 passed. Fresh Codex Sol xhigh structured review: clean (0.98). Exact-head hosted run IDs: CI 30720195761; Workflow Sanity 30720195766.Contributor commit
0ef01bcfc43cbbcff09a4853d8f86527ca6e48dapreserves @ZengWen-DT's original name, email, July 20 author date and unchanged production patch. Separately attributed maintainer test-only commitdf7d68ae08f1183ba3d2f724e348bcb36b0fadaeaccounts for newermain's independent provider error-body timers, keeps exact pending/retry poll assertions, and adds explicit retained HTTP 503 cause coverage.There is no persisted data model, SQLite schema, migration, embedding metadata, or embedding output change; this patch changes only in-memory provider request/poll timeout enforcement, despite generic filename-based embedding/storage heuristics.
Official provider Batch API/status contract: https://developers.openai.com/api/reference/resources/batches . Detailed maintainer evidence: #111675 (comment) .