fix(vector stores): refresh server poll intervals - #3775
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
I traced this through all four vector-store polling paths. The important part is that an omitted poll_interval_ms now remains omitted across iterations, so _get_poll_interval_ms(response.headers) is evaluated against each pending response instead of the first server hint becoming accidental caller state.
An explicit interval is still stable: it continues to set X-Stainless-Custom-Poll-Interval once and is selected on every iteration. When no server hint is present, _get_poll_interval_ms also preserves the existing 1000 ms fallback.
The two-response 100 ms -> 2000 ms regression directly pins the failure mode, and the shared parameterized test covers the sync/async file and file-batch entry points. I don't see a blocking behavior change beyond the intended response-scoped hint refresh.
Changes being requested
When
poll_interval_msis omitted, the vector-store polling helpers currently assign the first response'sopenai-poll-after-msvalue back topoll_interval_ms. That makes the value appear caller-specified on later iterations, so subsequent server hints are ignored.For example, two pending responses with 100 ms and 2000 ms hints currently sleep for
[0.1, 0.1]seconds instead of[0.1, 2.0].This change keeps an explicitly supplied interval fixed, while resolving an omitted interval from every pending response. The behavior now matches the response-scoped hint handling in the other OpenAI SDK polling implementations.
The regression covers all four public vector-store polling paths:
FilesAsyncFilesFileBatchesAsyncFileBatchesAdditional context & links
The patch is limited to the SDK-owned
src/openai/lib/_vector_stores.pyhelper and its focused tests. It does not change any public signature, request header, terminal-state behavior, or generated resource file.Validation:
[0.1, 0.1]../scripts/lint: Ruff, Pyright, mypy, and import check passedgit diff --check: passed