Skip to content

[codex] Expose sync timeout as queryable error#1

Merged
chengzeyi merged 1 commit into
mainfrom
codex/sync-timeout-errors
Jun 16, 2026
Merged

[codex] Expose sync timeout as queryable error#1
chengzeyi merged 1 commit into
mainfrom
codex/sync-timeout-errors

Conversation

@chengzeyi

Copy link
Copy Markdown
Member

What changed

  • Preserve code, created_at, and urls from sync-mode responses.
  • Detect server-side sync timeout and return a queryable error with task ID/result URL.
  • Treat sync timeout as non-retryable to avoid duplicate submissions.
  • Keep successful Run() return shape unchanged.
  • Return processing status plus TaskID/ResultURL from RunNoThrow() for sync timeout.
  • Updated README and added regression tests.

Why

A sync timeout means the prediction is still processing asynchronously. Go callers need to distinguish that from prediction failure and query the task later.

User impact

Run(..., WithSyncMode(true)) returns a non-nil error on sync timeout with the task ID/result URL. RunNoThrow() exposes the query data structurally in Detail.

Validation

  • go test ./...
  • git diff --check

@claude

claude Bot commented Jun 16, 2026

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@chengzeyi chengzeyi marked this pull request as ready for review June 16, 2026 17:35
@chengzeyi chengzeyi merged commit 268f200 into main Jun 16, 2026
1 of 2 checks passed
@chengzeyi chengzeyi deleted the codex/sync-timeout-errors branch June 16, 2026 17:35

@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: 8a68edd142

ℹ️ 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 README.md
Comment on lines +87 to +88
request. If the server-side sync wait times out, the SDK returns an error with
the task ID/result URL; the task continues processing and can be queried later.

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 Let sync POSTs outlive the connect timeout

With default client settings, this documented path only works if the server returns before 10 seconds: submit still sets http.Client.Timeout from c.connectionTimeout (10s default), so a server-side sync wait that times out after the API's longer wait window is cut off locally before the JSON body containing the task ID/URLs can be decoded. In that sync-timeout case callers get a generic client timeout (and task retries may resubmit) instead of the queryable task error promised here; the sync POST needs a read/request timeout based on the run timeout, or this doc must require increasing the connection timeout.

Useful? React with 👍 / 👎.

Comment thread api/client.go
Comment on lines +468 to +469
return syncResultCode(data) == 5004 ||
(status == "processing" && strings.Contains(errorMsg, "Sync mode timed out"))

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 Require processing status for sync timeout

When a sync response is already terminal with status: "failed" and code: 5004 (a task timeout/failure), this predicate treats the code alone as a still-processing sync-mode timeout. That makes Run() tell callers to query later and makes RunNoThrow() report Detail.Status == "processing", even though the task has failed; gate code 5004 on a non-terminal/processing status or the sync-timeout message instead of ignoring status.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant