Skip to content

fix: prevent queue consumer deadlocks - #4201

Merged
seratch merged 1 commit into
mainfrom
fix/queue-consumer-deadlock
Aug 5, 2026
Merged

fix: prevent queue consumer deadlocks#4201
seratch merged 1 commit into
mainfrom
fix/queue-consumer-deadlock

Conversation

@seratch

@seratch seratch commented Aug 5, 2026

Copy link
Copy Markdown
Member

This pull request fixes #4198 deadlocks that occur when streaming callbacks or sandbox memory workers terminate with CancelledError or another BaseException.

It builds on the core approach proposed by @abhay-codes07 in #4199: remove deadlock-prone Queue.join() waits and observe the consumer task directly. This version extends that approach by supervising producers and consumers together, preserving parent cancellation, guaranteeing Codex span cleanup, clearing failed memory worker state, and adding regression coverage for blocked producers and memory worker failures.

The original contributor is credited through the commit's Co-authored-by trailer.

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

ℹ️ 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 src/agents/agent.py Outdated
Comment thread src/agents/extensions/experimental/codex/codex_tool.py Outdated
Supervise streaming producers and consumers together so callback cancellation cannot strand an active stream. Await sandbox memory workers directly and preserve cleanup on failure.

Co-authored-by: abhay-codes07 <abhaysingh0293@gmail.com>
@seratch
seratch force-pushed the fix/queue-consumer-deadlock branch from d52a7dd to d150755 Compare August 5, 2026 10:43
@seratch
seratch merged commit 6af30c5 into main Aug 5, 2026
10 checks passed
@seratch
seratch deleted the fix/queue-consumer-deadlock branch August 5, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent.as_tool(on_stream=...) deadlocks forever when the handler raises a BaseException

1 participant