From 7b63c4955ae80387dfbe0dda737a8bed9d633da7 Mon Sep 17 00:00:00 2001 From: xxxigm Date: Wed, 27 May 2026 21:51:38 +0700 Subject: [PATCH] fix(codex): surface live tool-progress + commentary on app-server runtime (#33200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass ``on_event=make_codex_app_server_event_bridge(agent)`` when spawning the per-session ``CodexAppServerSession``. The session has always had a raw event hook but ``run_codex_app_server_turn`` never supplied one, so Discord / Telegram / TUI users saw nothing while codex was working — only the final answer landed. Now each ``item/started`` for a tool-shaped item fires ``tool_progress_callback("tool.started", ...)``, ``item/completed`` fires the matching ``"tool.completed"`` with duration + result, ``item/agentMessage/delta`` flows through ``_fire_stream_delta`` and each completed ``agentMessage`` surfaces through ``_emit_interim_assistant_message`` so the gateway's ``already_streamed`` dedupe keeps interim commentary in the channel without duplicating text the stream already showed. --- agent/codex_runtime.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/agent/codex_runtime.py b/agent/codex_runtime.py index 6584c845728d..584dc1b0bd2f 100644 --- a/agent/codex_runtime.py +++ b/agent/codex_runtime.py @@ -655,22 +655,13 @@ def run_codex_app_server_turn( exc_info=True, ) - def _on_codex_event(note: dict) -> None: - # Bridge Codex app-server item/started notifications to Hermes - # tool-progress so gateways show verbose "running X" breadcrumbs - # on this route too (#38835). - progress_callback = getattr(agent, "tool_progress_callback", None) - if progress_callback is None: - return - mapped = _codex_note_to_tool_progress(note) - if mapped is None: - return - tool_name, preview, args = mapped - try: - progress_callback("tool.started", tool_name, preview, args) - except Exception: - logger.debug("codex tool-progress callback raised", exc_info=True) - + # Bridge codex JSON-RPC notifications (item/started, item/completed, + # item/agentMessage/delta, ...) into Hermes' gateway UI callbacks + # (tool_progress_callback, _fire_stream_delta, + # _emit_interim_assistant_message). Without this, Discord/Telegram + # users see no live tool-progress or interim commentary while + # codex_app_server is running — only the final answer (#33200). + # Supersedes the narrower item/started-only bridge from #38835. agent._codex_session = CodexAppServerSession( cwd=cwd, approval_callback=approval_callback, @@ -678,7 +669,7 @@ def run_codex_app_server_turn( auto_approve_exec=auto_approve_requests, auto_approve_apply_patch=auto_approve_requests, ), - on_event=_on_codex_event, + on_event=make_codex_app_server_event_bridge(agent), ) # NOTE: the user message is ALREADY appended to messages by the