codex icon indicating copy to clipboard operation
codex copied to clipboard

Support automatic parent wake-up for create_thread assignments (explicit callbacks already work)

Open BrunoP9 opened this issue 2 weeks ago • 5 comments

What variant of Codex are you using?

Codex Desktop (Windows) and Codex CLI.

  • Desktop version: 26.1111.21308
  • Client version reported by usage data: 0.169.0-alpha.11.1
  • Parent model: gpt-6-astra
  • Test child model: gpt-6.1-sol (reasoning_effort: low)
  • Feature enabled in config.toml: wake_on_agent_messages = true

These version identifiers are reported by the application and usage data; I have not established that they correspond to an identical public source-code build.

What feature would you like to see?

Summary

Request: Add opt-in automatic parent notification and wake-up for independent threads created with mcp__codex_app__create_thread.

I confirmed two different behaviors in Codex Desktop:

  • Working: With wake_on_agent_messages = true, a child created with collaboration.spawn_agent can finish and automatically start a new turn in its idle parent.
  • Not working automatically: An independent child created with mcp__codex_app__create_thread did not wake its idle originating thread merely by finishing.
  • Working with an explicit callback: That independent child can reactivate the idle parent by calling mcp__codex_app__send_message_to_thread. I successfully reproduced a new parent model turn without owner input.

The missing capability is therefore not cross-thread wake-up itself. It is the automatic, reliable association between delegated work, a meaningful completion or intervention event, and notification of the originating parent.

I would like Codex to provide this as an opt-in relationship for independent threads. No parent-side wait, wait_threads, sleep, or model-driven polling should be necessary.

Architecture and use case

My development orchestration has three levels:

  1. Architect (root thread): Receives high-level assignments, delegates bounded development work to independent Orchestrator threads via mcp__codex_app__create_thread, and should finish its own turn immediately after delegation.
  2. Orchestrators (independent threads): Coordinate implementation, tests, reviews, and decisions over potentially long-running workflows. They may run multiple model turns before their assignment is complete.
  3. Workers: Specialized subagents created by Orchestrators with collaboration.spawn_agent, or isolated CLI processes for narrowly scoped tasks.

This separation is intentional. An Architect should be able to delegate work, remain idle, and resume only when a result, blocker, or decision actually needs its attention. I do not want to convert independent Orchestrators into native subagents solely to obtain notification behavior.

Reproduction and observed results

Test A: spawn_agent wakes an idle parent — SUCCESS

  1. Enabled [features] wake_on_agent_messages = true in the local Codex configuration.
  2. Started a fresh root session.
  3. Created a child with collaboration.spawn_agent; the child waited approximately 90 seconds and then completed.
  4. The parent printed a one-line start confirmation and ended its turn immediately, without waiting or polling.
  5. After child completion, the parent started a new model turn automatically, without owner input.

Observed: Automatic wake-up works for native spawned agents in this configuration.

Test B: create_thread completion does not automatically wake the parent — NO AUTO-WAKE OBSERVED

  1. Started a fresh root Architect thread with the same feature configuration.
  2. Launched an independent thread using mcp__codex_app__create_thread, model gpt-6.1-sol, low reasoning effort.
  3. Instructed the child to run Start-Sleep -Seconds 30, obtain a host timestamp, and reply with a short completion message.
  4. The Architect printed one confirmation and ended its turn without invoking wait, wait_threads, wait_agent, or sleep.
  5. No automatic new Architect turn was observed.

Observed: The test did not establish automatic parent activation from a standalone child-thread completion. It does not by itself locate the missing internal transition or prove whether any completion notification was delivered.

Test C: Explicit send_message_to_thread callback wakes an idle parent — SUCCESS

I ran a follow-up test on the same Windows Desktop installation on 17 November 2026 (Europe/Zurich).

  1. Started an independent child via mcp__codex_app__create_thread.
  2. Passed the existing Architect thread UUID to the child as the callback destination.
  3. The Architect ended its turn immediately. It did not poll or wait.
  4. The child waited approximately 30 seconds, then called mcp__codex_app__send_message_to_thread once, addressing the Architect explicitly.
  5. The Architect started a new model turn without owner input, acknowledged the received callback, and reported the host time 00:27:41 CET.

Observed: CALLBACK_WAKE_SUCCESS — a real parent model turn occurred, not merely a UI notification.

Important limits of this result: It proves the explicit callback works in this tested setup. It does not establish automatic child-completion delivery, the internal mechanism used by send_message_to_thread, or delivery guarantees under failure, restart, or concurrency.

Measured cost of model-driven polling

Before removing parent-side waiting, I measured one development package in which the Architect largely supervised independent work for about 3.5 hours.

Metric Measured value
Architect model requests 181
Median interval between requests 56 seconds
Average input per request ~150,000 tokens
Input served from cache 99.4%
Average output per request ~250 tokens
Architect wait calls 136
wait calls with yield_time_ms=55000 134
Additional exec calls 40
Architect API-equivalent cost ~$29
Full package API-equivalent cost $105.52
Implementation, reviews, and specialized workers combined ~$40

The Architect accounted for roughly 27.5% of the package's API-equivalent cost, mostly while checking the state of delegated work. The actual work was being done elsewhere.

These are estimates using API list prices, not actual charges or a measured conversion to Codex subscription limits. I am using them to compare the inference footprint of orchestration patterns, not to claim an exact subscription charge.

With a reliable notification path, the Architect can avoid repeated large-context wake-ups during periods when it has no work to do.

Expected behavior

When I create an independent thread for a delegated assignment, I should be able to opt into a callback relationship with the originating thread.

A new parent turn should be eligible to start on meaningful delegated-task events, such as:

  • Assignment completed: The child explicitly reports that the delegated work is finished and the result is available.
  • Blocked / input required: The child explicitly requests an owner or parent decision.
  • Assignment failed: The child or host reports a terminal failure that requires recovery or escalation.

A completed model turn is not necessarily a completed delegated assignment. Long-running Orchestrators may make many turns. They should not automatically wake the Architect after every intermediate turn. Progress notifications should not trigger expensive model turns unless explicitly requested.

Completion events should include a reliable child/delegation identity, status, and result reference. If the parent is idle and eligible for automatic execution, Codex should wake it without requiring a waiting tool call.

Suggested implementation

I am proposing behavior, not claiming that these parameters already exist. One possible opt-in interface would be:

{
  "wake_parent_on_completion": true
}

A more general API could register parent_thread_id, a stable delegation ID, event types, and an appropriate notification policy at create_thread time.

Based on my read-only examination of public Codex source at commit b08fd8a6f175b932b9abd0df68b1fc5ba7674ea9:

  • Native subagent result delivery selects SessionSource::SubAgent(ThreadSpawn { ... }) and routes results to its recorded parent. Completion routing.
  • The existing Core wake gate can start a new turn when eligible agent communication reaches an idle root. Wake admission.
  • The public App Server sends turn/completed notifications to subscribed client connections; that is not, by itself, a message in another thread's agent mailbox. Thread listener routing.
  • A public TUI mechanism already uses thread/resume followed by turn/start for explicit cross-thread messaging. This does not prove that the proprietary Desktop tool uses exactly that implementation. TUI callback.

Interpretation (not a proven Desktop root cause): The independent-thread path in my configuration does not automatically connect a meaningful child outcome to wake-eligible parent input. The missing piece could be origin registration, event routing, parent loading, or wake admission. The exact Desktop handler is not publicly verifiable.

I recommend reusing the existing wake and mailbox behavior where appropriate rather than building a second scheduler. A host-managed completion reporter or explicit App Server callback could be viable, provided that parent loading and user-stop semantics are respected.

Reliability requirements

  • Opt-in and compatibility: Independent threads remain independent unless a callback relationship is requested.
  • Assignment semantics: Do not equate every turn/completed with assignment completion. Require an explicit completion contract or associated goal/task state.
  • No duplicate work: Multiple children finishing close together must not cause concurrent duplicate parent turns. Callback/event IDs should support deduplication.
  • Correct stop behavior: Explicitly interrupted, stopped, or Plan-mode parents should not be restarted unexpectedly.
  • Unloaded parents: Preserve or queue results and distinguish delivery from loading a thread and starting a model turn.
  • Failures: Report host-detectable terminal errors even if the child crashes before it can send an explicit callback.
  • Selective wake-ups: Routine progress updates should not wake an otherwise idle parent unless requested.
  • Preserve existing behavior: collaboration.spawn_agent wake-up must continue to work.

Current workaround — confirmed working

My current normal-completion workaround is:

  1. The Architect launches an independent Orchestrator via create_thread, passing its own verified thread ID as a callback destination.
  2. The Architect immediately ends its turn. It does not wait or poll.
  3. When the delegated assignment is complete or needs intervention, the Orchestrator explicitly calls mcp__codex_app__send_message_to_thread once with a concise status and result reference.
  4. The Architect receives the message and begins a new model turn automatically.

I verified the cross-thread wake-up itself in Test C. I have not established that this pattern is robust against Orchestrator crashes, app restarts, concurrent completions, or delivery failures. Explicit callbacks also require each Orchestrator to follow the messaging convention.

Therefore, I am not requesting that Codex merely make cross-thread messaging possible. That already works in my test. I am requesting first-class automatic and reliable completion/intervention notification for independent delegated threads.

Acceptance criteria

  1. A root Architect can launch an independent create_thread child with an opt-in callback relationship, then end its turn immediately.
  2. A verified delegated-assignment completion, failure, or explicit intervention request can trigger a new eligible parent model turn with no owner input or parent-side polling.
  3. The parent receives the correct delegation ID, child identity, status, and result reference.
  4. Intermediate child-turn completions and ordinary progress updates do not automatically wake the parent.
  5. Multiple children, duplicate events, and a currently active parent do not cause concurrent or redundant parent turns.
  6. Explicit interruption, Plan mode, and user stop are respected; delayed delivery does not bypass those decisions.
  7. Results are not silently lost when the parent is temporarily unloaded or callback delivery fails; failures are observable.
  8. Native spawn_agent behavior remains unchanged.
  9. The feature can be disabled without changing existing independent-thread semantics.

Why this matters

Event-driven orchestration should not require a large model context to wake up every minute just to ask whether another thread has finished.

My tests now show that Codex already has both the ability to wake an idle parent for native subagents and a functional explicit cross-thread callback. I would like those capabilities connected through a reliable, opt-in lifecycle contract for independent threads.

No polling. No wasted context. No manual synchronization for normal operation.

Event-driven agent orchestration should work across threads, not just subagents.

Additional information

Related: #61571 addresses resuming a paused Desktop Goal; this request also covers independent delegated threads without requiring a Goal. I would prefer to keep the distinction explicit rather than assume the two requests are identical.

BrunoP9 avatar Nov 16 '26 22:11 BrunoP9

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #61571

Powered by Codex Action

github-actions[bot] avatar Nov 16 '26 22:11 github-actions[bot]

Thanks for the detailed source-level analysis. Excellent point.

I agree that automatic child lifecycle notifications must not inherit the authorization semantics of an explicit trigger_turn.

My intention is to reuse the existing wake-up infrastructure while preserving the normal eligibility checks for automatic execution, particularly interruption state, Plan Mode, and the parent-child authorization relationship.

The successful send_message_to_thread test demonstrates that cross-thread activation is already possible, but it does not establish that the explicit callback path is appropriate for automatic lifecycle notifications.

Your proposed regression matrix is valuable. I would also explicitly test multi-turn assignments to ensure an intermediate turn/completed event cannot be mistaken for completion of the delegated task.

Thanks for identifying this distinction. It is exactly the kind of implementation detail that should be addressed before introducing automatic cross-thread wake-up.

One source-level guard is worth preserving if independent-thread completion events are wired into the existing wake machinery: a child lifecycle notification is not the same authorization class as an explicit trigger_turn.

BrunoP9 avatar Nov 16 '26 23:11 BrunoP9

Host integration boundary and acceptance for dot-continuity #30

This is an owner-side API handoff based on public source contracts; it does not claim a live Desktop event was observed.

Dot-continuity PR #100 (head adfed90c65944160d790cd99113315ca7ee0d39a) implements the exact-turn result reader behind an injected transport, but the package has no production construction of that transport or parent admission caller: https://github.com/ClarusIubar/dot-continuity/pull/100 . The missing code therefore belongs at the Codex Desktop/App Server host bridge.

The public Codex App Server routes terminal lifecycle notifications to connections subscribed to that thread, not to an originating parent: https://github.com/openai/codex/blob/b08fd8a6f175b932b9abd0df68b1fc5ba7674ea9/codex-rs/app-server/src/request_processors/thread_lifecycle.rs#L569-L600 . Public core completion routing associates a parent only for the native SubAgent(ThreadSpawn) source: https://github.com/openai/codex/blob/b08fd8a6f175b932b9abd0df68b1fc5ba7674ea9/codex-rs/core/src/agent/control/completion.rs#L28-L125 . Explicit send_message_to_thread resumes a named thread and starts a turn; it is not an automatic lifecycle subscription: https://github.com/openai/codex/blob/b08fd8a6f175b932b9abd0df68b1fc5ba7674ea9/codex-rs/tui/src/dynamic_tools.rs#L706-L756 . The documented async command-hook contract runs in the background and does not start a turn on an idle session: https://developers.openai.com/codex/hooks .

Required host-owned contract:

  1. An opt-in delegation binding with stable delegation, parent thread/turn, child thread/turn, slot/generation, request/revision, and authorization identity.
  2. Natural terminal events with stable event ID, exact runtime/thread/turn, and completed/failed/interrupted status; durable receipt before result retrieval; replay after reconnect/restart without duplicate receipt or dispatch.
  3. Parent admission that atomically verifies exact binding, current authorization, idle/mode eligibility, and persistent user pause/resume state. It returns a durable accepted parent-turn ID and application ACK. An unknown send receipt remains quarantined; no resend until authoritative history proves non-acceptance for that exact key.
  4. Result retrieval may proceed only for the exact terminal turn and complete ordered items. Incomplete, conflicting, wrong-turn, or wrong-generation evidence yields UNKNOWN and no admission.
  5. A natural acceptance trace, with no owner message and before any manual thread read: event ID → durable receipt → parent turn ID → admission ACK → at most one same-slot follow-up turn and its exact result.

Negative acceptance cases: duplicate/reordered events, reconnect/restart, stale generation, wrong turn, incomplete result, failed read, parent busy/Plan mode, and persistent user pause each produce zero duplicate admission, zero false ACK, and zero unauthorized follow-up. Fixtures validate code only; the release acceptance must capture the natural host trace above.

ClarusIubar avatar Nov 23 '26 12:11 ClarusIubar

Thanks for the detailed analysis and the proposed host-side acceptance criteria.

I agree that reliable delegation identity, lifecycle event delivery, parent admission, and actual turn execution must be treated as distinct concerns.

My successful Desktop test confirms that explicit cross-thread callbacks can already start a new parent turn. What remains missing is the automatic, opt-in lifecycle integration.

I particularly agree with your emphasis on verifying actual parent-turn creation rather than merely acknowledging message delivery.

I'd prefer to keep the initial enhancement as small as practical, reusing existing Codex mechanisms while preserving interruption, Plan Mode, and user-stop semantics.

Thanks for contributing this perspective!

Host integration boundary and acceptance for dot-continuity #30

This is an owner-side API handoff based on public source contracts; it does not claim a live Desktop event was observed.

Dot-continuity PR #100 (head adfed90c65944160d790cd99113315ca7ee0d39a) implements the exact-turn result reader behind an injected transport, but the package has no production construction of that transport or parent admission caller: https://github.com/ClarusIubar/dot-continuity/pull/100 . The missing code therefore belongs at the Codex Desktop/App Server host bridge.

BrunoP9 avatar Nov 23 '26 16:11 BrunoP9

Follow-up: Runtime-enforced event-driven orchestration

I have now taken this concept one step further and implemented a working proof of concept directly in the Codex Rust core.

While this issue addresses automatic parent wake-up, the new feature request addresses the complementary part of the orchestration lifecycle: deterministic parent turn completion after delegation, eliminating unnecessary polling and inference.

Validated in the regular Codex Desktop application:

  • 29 native test scenarios.
  • Zero additional parent inference requests after delegation and before child completion.
  • Zero additional parent tool calls during that interval.
  • Event-driven parent turn initiation within 59 ms and 112 ms in two end-to-end tests.

Full proposal, reproduction steps, architecture, and measured results: #63464

Together, both features provide the foundation for genuinely event-driven agent orchestration.

BrunoP9 avatar Nov 23 '26 23:11 BrunoP9