Skip to content

Preserve queued agent mail across session eviction - #50087

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/4b55647f9ee9d1aaf3753f0688863bda81617327
Oct 1, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/4b55647f9ee9d1aaf3753f0688863bda81617327

Conversation

@copyberry

@copyberry copyberry Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Preserve queued agent mail across session eviction

Why

Unread queue-only messages prevented idle agents from unloading, and sending a
message to an evicted agent reloaded its session. Pending mail should not require
an idle recipient to occupy a loaded thread slot.

What changed

  • Retain queue-only mail in an in-memory runtime mailbox when a session unloads.
    Queue new messages for locally evicted agents without reloading them or
    starting a turn.
  • Add AgentControl::take_mailbox and AgentControl::watch_mailbox so sessions
    can consume retained mail and react to host mailbox notifications.
  • Preserve message order across eviction, reload, and subsequent follow-ups.
    Keep agents with outstanding durable sleep or turn-triggering mail loaded,
    and discard retained mail when an agent is removed or its tree shuts down.

Testing

Add integration coverage for retaining mail across eviction, sending while
unloaded, and ordering messages around a follow-up after reload. Add a host
controller test verifying that mailbox notifications wake wait_agent and
that the message is delivered exactly once.

## Why

Unread queue-only messages prevented idle agents from unloading, and sending a
message to an evicted agent reloaded its session. Pending mail should not require
an idle recipient to occupy a loaded thread slot.

## What changed

- Retain queue-only mail in an in-memory runtime mailbox when a session unloads.
  Queue new messages for locally evicted agents without reloading them or
  starting a turn.
- Add `AgentControl::take_mailbox` and `AgentControl::watch_mailbox` so sessions
  can consume retained mail and react to host mailbox notifications.
- Preserve message order across eviction, reload, and subsequent follow-ups.
  Keep agents with outstanding durable sleep or turn-triggering mail loaded,
  and discard retained mail when an agent is removed or its tree shuts down.

## Testing

Add integration coverage for retaining mail across eviction, sending while
unloaded, and ordering messages around a follow-up after reload. Add a host
controller test verifying that mailbox notifications wake `wait_agent` and
that the message is delivered exactly once.

GitOrigin-RevId: 4b55647f9ee9d1aaf3753f0688863bda81617327
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/4b55647f9ee9d1aaf3753f0688863bda81617327 branch from d7d6299 to 960e878 Compare October 1, 2026 20:17
@copyberry
copyberry Bot merged commit 960e878 into main Oct 1, 2026
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/4b55647f9ee9d1aaf3753f0688863bda81617327 branch October 1, 2026 20:17
@ZCSharp
ZCSharp deployed to issue-triage October 1, 2026 20:18 — with GitHub Actions Active
@ZCSharp
ZCSharp deployed to issue-triage October 1, 2026 20:18 — with GitHub Actions Active
@ZCSharp
ZCSharp deployed to issue-triage October 1, 2026 20:18 — with GitHub Actions Active
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 1, 2026
@DataDoesYou
DataDoesYou deployed to issue-triage October 1, 2026 20:26 — with GitHub Actions Active
@DataDoesYou
DataDoesYou deployed to issue-triage October 1, 2026 20:26 — with GitHub Actions Active
@DataDoesYou
DataDoesYou deployed to issue-triage October 1, 2026 20:26 — with GitHub Actions Active
@KSVQ
KSVQ deployed to issue-triage October 1, 2026 20:34 — with GitHub Actions Active
@KSVQ
KSVQ deployed to issue-triage October 1, 2026 20:34 — with GitHub Actions Active
@KSVQ
KSVQ deployed to issue-triage October 1, 2026 20:34 — with GitHub Actions Active
@dudasaus
dudasaus deployed to issue-triage October 1, 2026 20:40 — with GitHub Actions Active
@dudasaus
dudasaus deployed to issue-triage October 1, 2026 20:40 — with GitHub Actions Active
@dudasaus
dudasaus deployed to issue-triage October 1, 2026 20:40 — with GitHub Actions Active

This branch was successfully deployed

2 active deployments
pypi — 960e878d Deployed Oct 1, 2026 by andrewgu-oai via publish-python-sdk #209
issue-triage — 960e878d Deployed Oct 1, 2026 by dudasaus via Translate non-English issue #16727
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.

7 participants