Skip to content

Stop automatic compaction after turn cancellation - #5509

Merged
markstuart-oai merged 53 commits into
feat/codex-harnessfrom
fix/worker-stop-auto-compaction
Nov 5, 2026
Merged

markstuart-oai merged 53 commits into
feat/codex-harnessfrom
fix/worker-stop-auto-compaction

Conversation

@markstuart-oai

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

Copy link
Copy Markdown
Contributor

Requirements · REQ733 for owned cancellation and REQ738 for bounded waits and cleanup.

Summary

Cancelling a turn near its context limit could send one more model request to compact the conversation. A pending executor callback could settle after the SDK accepted cancellation but before Core received the interrupt.

Core checks the exact turn's stop receipt at the start of automatic compaction and again immediately before admitting an HTTP or WebSocket request. The second check covers cancellation while a pre-compaction hook is running. The existing cancellation API owns cleanup. An explicitly requested compaction and a later turn retain their own lifecycles.

An HTTP attempt admitted before cancellation can return a retryable error after cancellation starts. The Responses HTTP transport checks the issuing turn's stop receipt before each attempt, including retries. This lets the original request settle and prevents a new retry for the stopped turn. Other turns keep their normal retry policy.

This follows #5495.

Test plan

The installed previous wheel sent a second provider request over both HTTP and WebSocket when the test released a pre-compaction hook during cancellation. The regressions check that the stopped turn sends only its original request, and that a successor can compact and finish under its own turn ID.

The installed wheel passed both HTTP retry cases. When the first attempt returned a 503 after cancellation was reserved, the provider received zero retries and the caller received TurnStoppedError after the interrupt settled. With the same 503 on a live turn, the provider received a retry and the turn completed.

Issue number

The requirement IDs appear above.

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 4, 2026 17:33
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T02:23:33.868620Z 76b4900 New commits
🔒 Security Review ✅ Completed 2026-11-05T02:24:21.329761Z 76b4900 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.

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

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@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.

Automatic compaction now carries the owning turn stop state into provider prompts and checks it again at HTTP/WebSocket admission after hooks. Inspected native cancellation ownership, successor-turn isolation and the held-hook/result regressions; the previous late-admission feedback is addressed.

Re-reviewed this exact commit with an independent reviewer. Static inspection only; no candidate code or local tests executed. Hosted checks remain in progress.

@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.

Re-reviewing newly posted security feedback changes my decision at this commit. The existing hard-link finding is valid: openai/openai-agents-js#2122 (comment) .

With a preexisting same-filesystem hard link from a writable workspace to a user-owned installed helper, LocalWriteRoots records the workspace/root and mount-destination identities but not ordinary file aliases. The helper path therefore passes validation while the alias remains writable. A read-only bind at the installed path does not protect the shared inode through the writable alias; an inactive sibling helper can be modified before a later trusted launch, so ETXTBSY on a currently running executable is not a general defense. Reject or safely isolate ordinary hard-link aliases as well, and exercise the real constructor without synthetic mount entries.

This Python layer includes the equivalent LocalWriteRoots guard and inherits the same issue. The earlier fixes remain valid; this is a newly validated remaining blocker. Referencing the existing finding without duplicating its inline comment. Coordinator and independent static review only; no candidate code or local tests executed. Hosted platform checks remain unfinished.

@markstuart-oai
markstuart-oai force-pushed the docs/supervised-workers branch from 181eca9 to 77da2f7 Compare November 4, 2026 18:41
@markstuart-oai
markstuart-oai force-pushed the fix/worker-stop-auto-compaction branch from 4489003 to ac37b34 Compare November 4, 2026 18:41

@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.

Re-reviewed this exact commit after coordinator and independent static review. The outstanding helper hard-link and reverse bind-mount alias findings are fixed: multiply linked resolved helpers are checked inside grants, including the code-mode host; reverse mappings verify visible candidate inode identity and canonical location. Managed local process cleanup failures remain reported by the scoped tree shutdown check. No remaining actionable blocker found in this increment. The automatic-compaction patches are byte-identical to the previously reviewed versions after renumbering; inherited fixes were verified.

This approval supersedes my earlier request-changes decision after the relevant fixes. Hosted checks on the current commit are still pending/running; no candidate code or local tests were executed.

@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.

Requesting changes for the confirmed Python 3.10 test compatibility failure below. Hosted tests (3.10) finished with 6 failed, 3777 passed, 35 skipped. The failures are expected observation timeouts escaping the wrong exception handler, not evidence that cancellation admitted another request. Static source/log review with an independent reviewer; no candidate code or tests executed. Other pending hosted checks remain tracked.

@markstuart-oai
markstuart-oai force-pushed the docs/supervised-workers branch from 77da2f7 to 878426b Compare November 4, 2026 19:18
@markstuart-oai
markstuart-oai force-pushed the fix/worker-stop-auto-compaction branch from ac37b34 to 230e6ea Compare November 4, 2026 19:19

@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.

Request changes at 230e6ea for the existing P1 storage-hard-link finding; cross-linking it rather than adding duplicate inline feedback. Coordinator and independent static review confirm that the local executor checks helper-file inodes but checks storage_home only for path/symlink/mount overlap. On Linux, a pre-existing hard link inside a writable workspace to an existing profile SQLite file passes those checks; writes through the alias modify the same trusted DB inode. The SQLite opener has no independent hard-link rejection. Reject writable inode aliases to existing trusted storage before opening the local executor, and add a regression that reopens a profile with such an alias. This applies to the shared local-executor implementation in this stack.

The incremental macOS helper guard and trusted-wrapper resume changes are otherwise sound. Complete-artifact verification and the relevant documentation corrections are sound. The prior Python 3.10 timeout finding is fixed at both asyncio.TimeoutError handlers; compaction patches are unchanged apart from renumbering.

Static source review only; no candidate code/tests executed. Hosted CI remains unfinished.

@markstuart-oai
markstuart-oai force-pushed the docs/supervised-workers branch from 878426b to 879a08f Compare November 4, 2026 19:58
@markstuart-oai
markstuart-oai force-pushed the fix/worker-stop-auto-compaction branch from 230e6ea to 61991ac Compare November 4, 2026 19:59

@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 the current fix increment after coordinator and independent static reviews. The private-storage guard rejects writable hard-link aliases, including relocated SQLite databases and sidecars, while retaining path-overlap protection. Durable resume now validates receipt identities and rejects strict/nondefault sampled resumes without verifiable policy; recognized legacy defaults remain compatible. The Darwin wrapper-identity wait stays within the existing bounded shutdown join. Instruction-file provenance, compaction propagation, runner routing, and late-completion documentation/regressions were also reviewed in this increment. The prior storage finding is addressed; no new actionable issue found.

Hosted validation remains unfinished. No candidate code or local tests executed.

@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.

Re-reviewed 8fa83e6. The Linux long-path helper scan safely falls back to component-wise directory opens, rejects descendant symlinks, preserves distinct mount views, and keeps the directory descriptor alive through entry inspection. The patch and manifest propagation are consistent with the previously reviewed stack. No new actionable findings. Hosted CI remains in progress; this was static review only, with no candidate code or local tests executed.

@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.

Re-approved 6e5987ea2d5c9507c4c8fbcd2ec309b5f14ddfa1. The complete Git tree is identical to the previously approved commit. No source, configuration, documentation or test changes. Coordinator and independent static review found no new actionable issue.

Fresh hosted native CI remains pending. No candidate code or local tests executed; existing merge holds remain.

@jbeckwith-oai

Copy link
Copy Markdown
Contributor

Hosted CI follow-up at 76b4900: the Python 3.12 job failed test_stdio_retirement_joins_delayed_process_with_outstanding_request[True] after the 45-second timeout while waiting for the child cleanup_wait record at tests/test_native_owned_child_stdio.py:218. Result: 3,980 passed, 1 failed, 12 skipped. The non-cancellation case passed.

Job: https://github.com/openai/openai-agents-python/actions/runs/41954692912/job/127014527449

This test is byte-identical to the current base and previous head. The evidence does not establish a PR-specific regression or a flake, so my static approval stands, but cancellation-cleanup CI verification remains unresolved. Please investigate or obtain a passing hosted result before treating CI as complete. No candidate code or local tests run.

@markstuart-oai
markstuart-oai changed the base branch from docs/supervised-workers to feat/codex-harness November 5, 2026 03:17
@markstuart-oai markstuart-oai reopened this Nov 5, 2026
@markstuart-oai
markstuart-oai merged commit 13d4408 into feat/codex-harness Nov 5, 2026
103 of 104 checks passed
@markstuart-oai
markstuart-oai deleted the fix/worker-stop-auto-compaction branch November 5, 2026 04:13
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.

3 participants