Skip to content

fix: isolate chat event loops and persist pending input - #1891

Open
fcsguyxcw wants to merge 1 commit into
agent0ai:readyfrom
fcsguyxcw:codex/fix-cross-chat-event-loop-wedge
Open

fcsguyxcw wants to merge 1 commit into
agent0ai:readyfrom
fcsguyxcw:codex/fix-cross-chat-event-loop-wedge

Conversation

@fcsguyxcw

Copy link
Copy Markdown

Summary

  • give each AgentContext its own event-loop thread so one blocked chat cannot wedge unrelated chats
  • persist each UI message as a pending queue item before dispatch, then drain it in memory so the on-disk copy survives until normal loop completion saves the cleared state
  • add regressions for cross-chat loop isolation and pre-dispatch message durability

Root cause

Every chat constructed DeferredTask(thread_name="AgentContext"). EventLoopThread is a singleton by name, so all chats ran on one asyncio loop; one synchronous blocker stopped every chat at once. UI messages were only held in memory before dispatch and chat persistence normally happened at message-loop completion, so a wedge could leave no durable record.

This is separate from #1793 / #1794: those address unsafe teardown of shared loop threads; this change removes cross-chat sharing at the AgentContext boundary.

Fixes #1889

Verification

  • pytest tests/test_agent_context_event_loop_isolation.py tests/test_message_durability.py tests/test_defer_lifecycle.py -q — 7 passed
  • py_compile passed for all changed Python files
  • git diff --check passed

Additional neighboring suites could not collect in the existing local environment because optional pathspec and crontab packages are absent.

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.

1 participant