Skip to content

Avoid persisting ShutdownComplete after thread shutdown#19630

Merged
etraut-openai merged 1 commit intomainfrom
etraut/fix-exec-shutdown-rollout-error
Apr 28, 2026
Merged

Avoid persisting ShutdownComplete after thread shutdown#19630
etraut-openai merged 1 commit intomainfrom
etraut/fix-exec-shutdown-rollout-error

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented Apr 26, 2026

Why

Fixes #19475.

codex exec can finish successfully and then emit an ERROR on stderr:

failed to record rollout items: thread <id> not found

That happens because shutdown closes the live thread writer before emitting ShutdownComplete. The terminal event was still using the normal send_event_raw path, so it tried to append rollout items through a recorder that had already been removed. The answer is correct, but wrappers that treat stderr as failure can retry completed exec runs.

This looks like a likely recent regression from #18882, which routed live thread writes through ThreadStore and added the shutdown-time live writer close. I have not bisected this, so the PR treats #18882 as the likely source based on the affected shutdown code path rather than a proven first-bad commit.

What Changed

ShutdownComplete now bypasses rollout persistence after thread shutdown and is delivered directly to clients. The shutdown path still records the protocol event in the rollout trace before delivery, preserving trace visibility without attempting a post-shutdown thread-store append.

The change also adds a regression test with the in-memory thread store to assert that shutdown creates and shuts down the live thread without appending another item after shutdown.

@etraut-openai etraut-openai merged commit 5ba908d into main Apr 28, 2026
35 of 36 checks passed
@etraut-openai etraut-openai deleted the etraut/fix-exec-shutdown-rollout-error branch April 28, 2026 05:02
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codex exec on Windows: every invocation emits failed to record rollout items: thread <uuid> not found for the just-created session

2 participants