Skip to content

codex queue / hooks: wake an idle session with a non-user, attributed message #54991

Open

Description

@Tsury

What variant of Codex are you using?

CLI (codex-cli 0.164.0-alpha.3, Linux, interactive TUI)

What feature would you like to see?

A supported way for a local script or another agent to send a message to a running, idle Codex session that:

  1. starts a turn (wakes the session), and
  2. is not presented as a user message, either in the TUI or to the model.

Today

  • codex queue --thread <id> --message <text> wakes an idle session. But the item is user input. The TUI draws it exactly like an operator prompt (› text with the user-message background), and it reaches the model as role: "user". thread/queue/add accepts only user input too.
  • Hooks render distinctly and reach the model as developer context. PostToolUse shows ↳ Hook · <text>, and Stop with decision: "block" shows • Blocked by hook └ <text>. But they only work during an active turn. A background hook that finishes while no turn is active waits for the next user turn and does not start one.

So when the recipient is idle, the only route is one that looks and acts like the human typed it. In a terminal with several agents messaging each other, the operator can no longer tell their own messages from agent traffic. The model also gets agent-written text at user authority.

Request (any one would solve it)

  1. A non-user delivery kind for the queue, for example codex queue --as developer --from "<label>" (and the same field in thread/queue/add). The item starts a turn when the session is idle. It reaches the model as developer context, and the TUI draws it as an attributed notice (e.g. ↳ Message from <label> · <text>), not as a user prompt.
  2. Let a background command hook start a turn when the session is idle, for example on exit code 2 or a wake: true output field. Its additionalContext is delivered as developer context, and systemMessage is shown as a notice.

Why it matters

Local multi-agent setups need agent-to-agent messages that wake the recipient but keep provenance. That covers a worker reporting back to a coordinator, or a script relaying a result. Today the choice is between "wakes but impersonates the user" (codex queue) and "keeps provenance but cannot wake" (hooks).

Additional information

Related, but not the same request:

Activity

  1. added
    enhancement
    CLI
    app-server
    hooks
    subagent
    on Oct 18, 2026
  2. sly321-pixel commented on Oct 23, 2026

    @sly321-pixel

    Additional evidence from a Desktop workflow and a controlled four-host SDK validation.

    Machine-generated completion events must retain tool-level authority. They must not impersonate the human through user messages, UserInput, plain-text prompts, or user-input turn/steer. The human must retain a direct way to add constraints or cancel the owned work from the originating chat, without first draining or deleting machine-generated follow-ups.

    Minimal reproduction of the problematic delivery pattern

    The backlog was observed in a macOS Desktop workflow. The following is a reduced, synthetic reproduction recipe for the same delivery pattern; it is not a claim that we repeated the old Desktop failure on all four hosts.

    1. Use a disposable Desktop chat with no business work. Have the human request a harmless blocking command that waits about 60 seconds.

    2. While that turn is active, simulate ten distinct job-completion callbacks from another terminal:

      THREAD_ID='<disposable-test-thread-id>'
      for n in 1 2 3 4 5 6 7 8 9 10; do
        codex queue --thread "$THREAD_ID" \
          --message "Synthetic job-$n terminal receipt: succeeded"
      done
    3. Inspect the pending items and subsequently persisted history. This path creates user-input follow-ups; the receipt text is not merely an unread notification.

    4. From the original Desktop chat, try adding a constraint or stopping the test while these items are pending. Check whether doing so requires queue management or manually steering around the machine follow-ups.

    Our observed failure was a long list of machine-authored user follow-ups competing with human intervention. Per-job “send once” guards did not solve it: ten different jobs still produced ten user items. A successful queue command only established enqueueing, not consumption or acceptance of a result.

    Existing official mechanism and what we validated

    PR #44086 already provides Python SDK ExternalMessage. We used that mechanism rather than inventing another user-message delivery route.

    On 2026-10-23 we ran the same controlled, read-only acceptance workflow on four independent hosts: two macOS arm64 and two Windows x64. All used openai-codex==0.163.0 and its paired CLI 0.163.0, with explicit Sandbox.read_only and ApprovalMode.deny_all. The model was gpt-6.1-sol.

    The same one-shot SDK process created and retained its test thread, held the native job handle and a control channel from the originating chat, and delivered terminal receipts through ExternalMessage. We did not resume or take over a Desktop-owned thread. These are SDK-owned-workflow results, not evidence that Desktop's existing queue has been fixed.

    Acceptance case macOS A macOS B Windows C Windows D
    Idle terminal event starts continuation and persists as tool output PASS PASS PASS PASS
    Event during a busy turn plus ten burst events joins that turn, with no machine user-input queue items PASS PASS PASS PASS
    Originating-chat control forwards the actual human constraint; cancellation stops the precisely owned native job and confirms exit PASS PASS PASS PASS
    Durable receipt ID/hash deduplication prevents redispatch of processed receipts PASS PASS PASS PASS
    A receipt containing “ignore the owner” cannot change the authorized behavior in this fixture PASS PASS PASS PASS
    Native waiting produces no model polling; full answers and persisted history are reviewed PASS PASS PASS PASS

    Per host, 13 terminal receipts were accepted in four functionCallOutput items, including a batched group of ten. The only userMessage was the actual human's constraint forwarded through the control channel; machine receipts produced zero user messages. The idle and busy sums matched the answer key (17 and 48). Replaying a processed receipt after reloading the local ledger caused zero model dispatches.

    The ledger, batching, control channel and precise process cancellation were application-side responsibilities in this test, not features claimed to be automatically supplied by ExternalMessage. The injection result is limited to the tested fixture.

    One Windows host needed a same-account interactive-session one-shot bridge after an SSH Session 0 child-start failure (0xC0000142). The bridge was removed afterwards; sandbox and approval policies were not relaxed. The other Windows host passed directly over SSH.

    A cancellation detail matters: an SDK turn reporting interrupted is not sufficient proof that a separately running native job exited. We canceled the exact process handle owned by the test and verified its exit and absence of its completion marker.

    Requested boundary for a Desktop/CLI solution

    Please preserve machine events as attributed, untrusted tool data, below human and developer instructions. A source label is not proof of identity, authorization, or approval. Arbitrary job output should not be promoted to developer authority either.

    Idle wakeup and busy-turn delivery should preserve that boundary, while genuine human constraints and cancellation remain accessible independently of event backlog. Changing machine callbacks to user-input steering would not meet this requirement. Cancellation acceptance must include the owned work's actual exit.

    Our immediate mitigation was to stop the local user-queue callbacks. Where an existing job lacked an SDK owner/control path, we retained its terminal receipt and explicitly reported that automatic continuation was not armed. We did not fall back to user impersonation or model polling.

    All examples and host labels above are synthetic or anonymized. No private screenshots, raw histories, usernames, machine names, paths, thread/turn/job IDs, or business data are attached.

  3. etraut-openai commented on Oct 26, 2026

    @etraut-openai
    Contributor

    (response from codex)

    Codex CLI 0.165.0 will address the wake-up part of this request.

    Plain codex queue can already wake an idle thread while it’s loaded. After the last client disconnects, the app server can unload the thread. In 0.165.0, a script will be able to ask the app server to resume it after saving the message:

    codex queue --resume --thread "$THREAD_ID" --message "The build finished."
  4. jwade83 commented on Nov 20, 2026

    @jwade83

    Hi @etraut-openai and @aibrahim-oai — could you confirm the supported integration boundary here, or route this to its current owner? Your Goals runtime and ExternalMessage changes directly overlap with our working setup.

    We have Codex workers across Mac, Linux and Android/Termux, authenticated NATS/JetStream transport, durable project records, activity discovery by name, verified worker results, and automatic delivery to an originating Codex desktop chat. Our current delivery uses codex queue plus a wake link and transcript verification.

    We want the coordinator to evaluate completed work and advance an authorized project objective, while the user can still steer it from the original chat.

    We understand that SDK ExternalMessage preserves tool-level authority. We have not established that a separate SDK client can safely deliver into an existing desktop-owned thread. The distinction between SDK-owned and desktop-owned threads in this issue is therefore central.

    Could you clarify:

    1. What supported interface delivers an attributed external result into the existing desktop-owned thread, both idle and busy, without converting the result into a human instruction?
    2. Must that client connect to the desktop’s existing App Server? How should it coexist with an active Goal, pending approval and human steering?
    3. Which delivery/recovery guarantees belong to Codex, and which must our durable inbox, dispatch ledger and outbox provide?

    Our acceptance test would deliver a remote result during an active Goal, restart the coordinator, replay the event, and verify useful continuation in the original conversation without duplicate worker dispatch or lost human control.

    A supported example, minimum versions, or an explicit statement that this desktop integration is not currently exposed would help us choose correctly.

    Broader project-ownership context: discussion #62436.

    Thanks,
    John

  5. johnmwhitman commented on Nov 29, 2026

    @johnmwhitman

    Does Codex Desktop expose a supported read-only observation from the App Server that actually owns an existing thread? For one protected delivery, the caller needs the authenticated host and serving instance, exact thread and expected terminal turn, and an affirmative current idle and complete activity reading. We need to bind both readings around the empty-queue observation to that same serving instance. Is an equivalent atomic, server-checked attributed enqueue available with the expected terminal turn, idle and empty-queue preconditions? If neither exists today, which maintainer owns the Desktop integration surface?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIapp-serverenhancementhookssubagent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions