Skip to content

feat: add timeout result policy for Codex function tools - #5605

Merged
markstuart-oai merged 2 commits into
feat/codex-harnessfrom
markstuart/req95-tool-timeout-policy
Nov 8, 2026
Merged

markstuart-oai merged 2 commits into
feat/codex-harnessfrom
markstuart/req95-tool-timeout-policy

Conversation

@markstuart-oai

@markstuart-oai markstuart-oai commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This pull request adds a timeout result policy for Codex function tools. Set timeout_behavior='error_as_result' with callback_timeout to return failed text when a callback exceeds its deadline. timeout_error_function can format that text using the tool context and a typed ToolTimeoutError. The default still raises an exception and fails the turn; the new error remains a TimeoutError.

The SDK waits for entered callback cleanup before it formats the timeout result. Failed timeout output bypasses success validation and the after hook. Parent cancellation prevents late output and retains callback cleanup failures. The body task delivers failures to its owner without retaining rejected return values or letting process-control exceptions escape into the event loop. A timeout does not undo side effects or forcibly stop work that ignores cancellation. Selected MCP function-tool adapters retain these settings. The change includes an example and updates the public API snapshot without changing release metadata.

Test plan

  • Full repository verification passed: format, lint, type checks, 5,592 parallel tests (253 skipped), and 54 serial tests.
  • A focused run passed 135 cases covering timeout policy, cleanup, return-value privacy, deadlines, sync callbacks, selected MCP adapters, and isolated process-control errors.
  • Independent API and lifecycle reviews found no remaining issues. The reviewed source was unchanged after full verification.
  • Native tests used a qualified runtime artifact with unchanged native inputs and mock providers. Live-provider and local Linux sandbox behavior were not exercised.

Issue number

No linked GitHub issue.

Checks

  • I've added new tests, if relevant
  • I've run the applicable checks in AGENTS.md, including .agents/skills/code-change-verification/scripts/run.sh when required
  • I've confirmed all required checks pass
  • I've completed the review required by AGENTS.md

@markstuart-oai
markstuart-oai requested review from a team, rm-openai and seratch as code owners November 8, 2026 03:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T03:47:32.654853Z 85898e2 New commits
🔒 Security Review ✅ Completed 2026-11-08T03:48:39.335546Z 85898e2 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved at be4737f. Static review covered the public API and exports, captured settings and selected MCP adapters, deadline ownership, joined async/sync cleanup, parent cancellation, formatter admission and failures, late-result suppression, and root/child/parallel invocation coverage. No actionable findings. Hosted CI is still running with no failures observed; no local code or tests were run.

@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: be4737f9f1

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

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Superseding my earlier approval: I missed the new child-task boundary issues and have now independently confirmed the existing findings. Request changes at be4737f.

  1. Release the completed body task after extracting its outcome, before validation/after-hook failures can retain it and expose rejected callback payloads through traceback locals: #5605 (comment)
  2. Preserve non-cancellation body cleanup failures in the owning state when parent cancellation wins. _close_after_error attaches the failure to CancelledError, but the outer handler discards that cancellation without retaining the cleanup error: #5605 (comment)
  3. Capture process-control exceptions inside the child task and transport them to the parent; SystemExit/KeyboardInterrupt must not escape the task and abort the event loop: #5605 (comment)

Please add regressions for these boundaries. Referencing existing discussions rather than duplicating inline findings. Static review only; no candidate code or tests run. Hosted CI remains pending.

@markstuart-oai
markstuart-oai force-pushed the markstuart/req95-tool-timeout-policy branch from be4737f to 85898e2 Compare November 8, 2026 03:46

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved at 85898e2. All three earlier findings are resolved: the child task returns None and keeps output in the parent cell cleared on validation failure; cancellation and revoked admission retain non-cancellation cleanup failures in owner state; BaseException is transported out of the child without process-control exits escaping asyncio, then handled by the existing owning invocation boundary. Reviewed the exact old/new source changes separately from the rebased documentation base, along with privacy, cancellation/close, and process-control regression coverage. No additional actionable findings. Hosted CI is still running with no failures observed. Static review only; no local code or tests run.

@markstuart-oai
markstuart-oai merged commit 6701c7c into feat/codex-harness Nov 8, 2026
56 of 57 checks passed
@markstuart-oai
markstuart-oai deleted the markstuart/req95-tool-timeout-policy branch November 8, 2026 04:14
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.

2 participants