Skip to content

The agent that grows with you

fix(gateway): keep the reply-text reasoning block for ACP sessions

yoniebans5fea5a7a4bf6
diff --git a/gateway/run_turn_persistence.py b/gateway/run_turn_persistence.py
index dbe6edd9938..3aa7d3fbaff 100644
--- a/gateway/run_turn_persistence.py
+++ b/gateway/run_turn_persistence.py
@@ -41,6 +41,16 @@ if TYPE_CHECKING: # string annotations only; never imported at runtime (cycle)
logger = logging.getLogger("gateway.run")
+def _acp_launch(runner, source) -> bool:
+ """An editor session: ACP shows no reasoning event yet, so its reply keeps the projected block."""
+ from gateway.session_setting_commands import local_policy
+ from hermes_state_runtime import RuntimeStoreError
+ try:
+ return getattr(local_policy(runner, source), "source", None) == "acp"
+ except RuntimeStoreError: # a local route with no restored policy is not an editor launch
+ return False
+
+
class GatewayTurnPersistenceMixin:
async def _hmwa_shape_agent_response(
self, agent_result, source, history, session_entry, session_key,
@@ -143,7 +153,7 @@ class GatewayTurnPersistenceMixin:
def _hmwa_prepend_reasoning(self, agent_result, response, source, _intentional_silence):
"""Prepend the last reasoning block when show_reasoning is on for this platform. Mattermost
requires an explicit per-platform opt-in (scratch text, not final-answer content)."""
- if source.platform == Platform.LOCAL:
+ if source.platform == Platform.LOCAL and not _acp_launch(self, source):
# Local viewers receive reasoning.delta through their event stream; projecting it into
# the final response duplicates it and leaks messaging-platform formatting into Desktop.
return response