The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): finite codex app-server turns print the reply and release the app-server
teknium111eed5b7d4d8
diff --git a/gateway/run_turn_runner.py b/gateway/run_turn_runner.pyindex 00f820b17b9..6b9bea42e90 100644--- a/gateway/run_turn_runner.py+++ b/gateway/run_turn_runner.py@@ -146,7 +146,11 @@ class TurnRunner(GatewayTurnProgressMixin, GatewaySessionAgentMixin):# display.platforms.<plat>.streaming may disable streaming per platform; None = follow global.plat_streaming = ctx.resolve_display_setting(ctx.user_config, platform_key, "streaming")want_stream_deltas = not ctx.scheduled_heartbeat and scfg.enabled_for(plat_streaming)- want_interim_messages = bool(ctx.interim_assistant_messages_enabled) and not ctx.scheduled_heartbeat+ # A finite (`-z`, `chat -q`) viewer prints only the terminal reply, like the classic quiet+ # CLI that never wired commentary. Commentary it cannot see must not be recorded as a+ # delivery, or a final that arrives as commentary (codex app-server) suppresses the reply.+ want_interim_messages = (bool(ctx.interim_assistant_messages_enabled) and not ctx.scheduled_heartbeat+ and not _finite_viewer_turn())if want_stream_deltas or want_interim_messages:try:from gateway.stream_consumer import GatewayStreamConsumer@@ -1117,6 +1121,12 @@ class TurnRunner(GatewayTurnProgressMixin, GatewaySessionAgentMixin):persist_msg, persist_ts = self._prepare_turn_message(agent_history)result = self._run_conversation_with_approval(agent, agent_history, observed_group_context, persist_msg, persist_ts)self._finish_stream_consumer(result, agent_history, stream_consumer)+ if _finite_viewer_turn() and getattr(agent, "_codex_session", None) is not None:+ # The classic `chat -q` process exit bounded the codex app-server child; a finite turn+ # hosted here must too, or every one-shot leaves one running until the idle-TTL sweep.+ # Like a fresh process, the next turn respawns it and resumes the stored thread.+ agent._close_codex_session()+ agent._codex_session_prompt = None# The streaming-TTS consumer's finish() runs on the outer loop thread after the executor# returns, so early run_sync returns are also finalised.# See the outer finally/completion section below. See #60671.