Skip to content

feat: add document completion polling helper - #450

Open
denis-samatov wants to merge 4 commits into
VectifyAI:mainfrom
denis-samatov:feat/issue-122-wait-until-completed
Open

feat: add document completion polling helper#450
denis-samatov wants to merge 4 commits into
VectifyAI:mainfrom
denis-samatov:feat/issue-122-wait-until-completed

Conversation

@denis-samatov

@denis-samatov denis-samatov commented Aug 31, 2026

Copy link
Copy Markdown

Summary

  • add a public synchronous wait_until_completed(doc_id, timeout, poll_interval) helper that returns completed document metadata
  • preserve submit_document(wait=True) behavior by delegating its wait path to the new helper
  • use monotonic deadlines, bounded backoff, transient-error retries, and immediate handling of definitive 401/403/404 responses
  • bound each cloud metadata request by the remaining deadline and reject responses that arrive after it
  • document submit-now/wait-later usage and cover cloud-style plus real local-client behavior

Addresses the synchronous polling-helper portion of #122. Async client support and webhooks remain outside this PR's scope.

Test plan

  • python -m pytest -q without optional agent SDKs: 327 passed, 141 skipped
  • python -m pytest -q with openai-agents, claude-agent-sdk, and anthropic: 465 passed, 3 skipped
  • polling and cloud request wiring selection: 33 passed
  • git diff --check upstream/main...HEAD

Environment note

Installing the latest unpinned optional SDKs currently makes pip check report that openai-agents 0.22.0 installs openai 3.6.0, while litellm 1.97.0 declares openai<3.0.0. The full framework-enabled test suite still passes; this PR does not change dependencies.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread pageindex/client.py Outdated
status = None
try:
status = self.get_document(doc_id).get("status")
document = self.get_document(doc_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@denis-samatov

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: ab9335e677

ℹ️ 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant