Skip to content

Preserve cancellation when a synchronous tool raises - #6374

Merged
markstuart-oai merged 1 commit into
v1-alphafrom
fix/v1-tool-cancellation
Dec 2, 2026
Merged

markstuart-oai merged 1 commit into
v1-alphafrom
fix/v1-tool-cancellation

Conversation

@markstuart-oai

@markstuart-oai markstuart-oai commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This pull request fixes a case where a cancelled @function_tool handler raised the worker's exception instead of CancelledError. This happened when a caller awaited tool.handler(...) directly and the synchronous function failed after cancellation.

The handler still waits for the worker to finish. Cancellation now takes precedence over a late tool failure. Uncancelled calls and the storage and approval paths keep their existing error handling.

Test plan

All 60 focused tests passed. The new cases cover repeated cancellation, late success and failure, and an uncancelled exception. I also checked cancellation in normal agent turns and approval callbacks.

Formatting, lint, and type checks passed. The test suite passed 296 tests in the local sandbox. Five tests that start their own sandbox failed there. All five passed when I ran them separately on Linux.

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

@markstuart-oai
markstuart-oai requested review from a team, rm-openai and seratch as code owners December 2, 2026 19:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 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-12-02T19:32:09.301206Z 5168755 PR opened
🔒 Security Review ✅ Completed 2026-12-02T19:33:26.365639Z 5168755 PR opened
ℹ️ 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.

Comprehensive static review including independent review. Checked repeated cancellation, late worker success and failure, exception-context handling, async handler dispatch, and unchanged storage and approval behavior. No actionable findings. Hosted CI observed: {"success": 19, "skipped": 2, "in_progress": 1}. No candidate code or local tests were executed.

@markstuart-oai
markstuart-oai merged commit 935f25b into v1-alpha Dec 2, 2026
24 checks passed
@markstuart-oai
markstuart-oai deleted the fix/v1-tool-cancellation branch December 2, 2026 19:44
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