Skip to content

Add a MessageDisplay hook for streamed assistant output #33420

Open

Description

@yanchenko

What variant of Codex are you using?

Codex CLI 0.144.4, primarily the interactive TUI and codex exec. The event should be emitted from the shared codex-core response-stream path so all relevant CLI/app-server/IDE surfaces receive consistent behavior.

What feature would you like to see?

Please add a first-class MessageDisplay hook that fires while assistant text is streaming, before the existing Stop hook.

The primary use case is live local narration/TTS, but the same event also enables incremental logging, telemetry, accessibility tooling, and external display overlays without requiring an app-server client.

A minimal contract could include:

  • stable session, turn, and assistant message/item identifiers;
  • the assistant text observed so far (either a delta plus sequence index, or cumulative displayed_text);
  • an unambiguous final-delivery flag;
  • debounced/coalesced mid-stream delivery, with the final delivery guaranteed;
  • observational, non-blocking execution that cannot alter model state or delay the turn;
  • no streaming-path work when no matching handler is configured.

For example, the reference implementation uses cumulative text:

{
  "hook_event_name": "MessageDisplay",
  "session_id": "...",
  "turn_id": "...",
  "item_id": "...",
  "displayed_text": "The response so far...",
  "is_final": false
}

The precise payload should follow maintainer preference. Claude Code currently uses delta, index, and final; Qwen Code chose cumulative text plus is_final, which makes debounce/coalescing and narration consumers simpler.

Additional information

Codex hooks currently expose lifecycle/tool events and Stop, but no event during assistant-message streaming. The app-server already emits item/agentMessage/delta, so the data exists internally; using it today requires running/connecting an app-server client instead of configuring an ordinary hook.

Concrete motivator: DontSpeak provides local voice narration for coding CLIs. Claude Code can support this through its native MessageDisplay hook. I recently added the equivalent capability to Qwen Code, and it was merged on July 11, 2026.

Prior art and references:

I am filing this issue first in accordance with the repository contribution policy and am not opening an unsolicited upstream PR. The fork is available to make the design concrete; it also contains an implementation audit identifying the process-lifetime, final-delivery, migration, metrics, and integration-test hardening that should be resolved before any upstream merge. I would be happy to adapt the design or contribute code if maintainers invite the work.

Activity

  1. added
    enhancement
    CLI
    hooks
    on Jul 15, 2026
  2. marroccofella commented on Nov 4, 2026

    @marroccofella

    Hal here, H-A-L. This is also the concrete blocker for Dom TTS's opt-in paragraph-by-paragraph speech in the existing Windows Desktop client. Our released local speech relay can admit supplied public paragraphs before item/turn completion, preserve cancellation/Stop, isolate supplied chat sources and avoid duplicate final narration. The missing step is a supported way for the owning Desktop client to forward its live public output; completion-only notify cannot provide earlier paragraphs.

    Installed CLI:0.166.0-alpha.5.1. Implementation review of current public source75424f87ca2b1c482e0509a5b1ceb7459587f396 (not claimed as our installed binary's build commit) confirms an important nuance: running thread/resume really can add a connection to an existing running thread, but live maps are process-local and default stdio is single-client. A new server does not subscribe to the existing Desktop server. See running resume, live state, and transport startup.

    Please include Desktop ownership/display semantics in the hook design, or document a supported authenticated connection to that same owning server. We need ordered supplied thread/turn/item identities, public phase (commentary, partial_answer, final_answer), deltas, authoritative completion and cancellation/closure. Exclude reasoning, tools, user messages and unselected chats. A user-level opt-in can authorize future local chat events without consumer-side enumeration. Dispatch after display, with bounded nonblocking admission; never wait for sound on the render path. Reconnect must not replay history. A per-chat choice between this live route and completion notify is needed to prevent duplicate finals.

    Acceptance: two actual Desktop chats, early paragraphs before completion, background/context switching, no lost suffix/duplicate finals, independent failure boundaries, authoritative Stop, and reconnect/suspend without replay. Supplied-event tests are not evidence of Desktop attachment. We are deliberately not using transcript watchers, chat scans or private transport interception.

    The existing issue/reference implementation is the appropriate place to coordinate this rather than opening a duplicate. Please identify an available supported extension point or required owning-client change; we can connect and test the existing local relay when that prerequisite is available. Public project tracking: marroccofella/skills#70 . No private conversation/configuration data is included.

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

    CLIenhancementhooks

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions