feat: add document completion polling helper - #450
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c82434e15
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| status = None | ||
| try: | ||
| status = self.get_document(doc_id).get("status") | ||
| document = self.get_document(doc_id) |
There was a problem hiding this comment.
Enforce the deadline during each status request
When a cloud metadata request starts before the deadline but takes longer than the remaining timeout, this call can block for the hard-coded 30-second request timeout in CloudAPI.get_document; if the late response is completed, the method returns it without rechecking the deadline. Thus wait_until_completed(..., timeout=1) may take roughly 30 seconds and can even report success after its advertised timeout. Bound each status request by the remaining time and enforce the deadline after it returns.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ab9335e. Cloud metadata polling now uses min(30s, remaining deadline) as the request timeout, then rechecks the monotonic deadline before accepting a response; late completed responses therefore raise the polling timeout instead of succeeding. Added regression coverage for a 1s deadline with a 1.5s response and for preserving the existing 30s request cap. Current full suites: 327 passed / 141 skipped without optional SDKs, and 465 passed / 3 skipped with them.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
wait_until_completed(doc_id, timeout, poll_interval)helper that returns completed document metadatasubmit_document(wait=True)behavior by delegating its wait path to the new helperAddresses the synchronous polling-helper portion of #122. Async client support and webhooks remain outside this PR's scope.
Test plan
python -m pytest -qwithout optional agent SDKs:327 passed, 141 skippedpython -m pytest -qwithopenai-agents,claude-agent-sdk, andanthropic:465 passed, 3 skipped33 passedgit diff --check upstream/main...HEADEnvironment note
Installing the latest unpinned optional SDKs currently makes
pip checkreport thatopenai-agents 0.22.0installsopenai 3.6.0, whilelitellm 1.97.0declaresopenai<3.0.0. The full framework-enabled test suite still passes; this PR does not change dependencies.