Add a MessageDisplay hook for streamed assistant output

Open 💬 0 comments Opened Jul 15, 2026 by 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.

View original on GitHub ↗