Skip to content

The agent that grows with you

perf(cli): filter the gateway subagent tail once per fetch, not per frame

kshitijk4poorbe4164bb8bb1
diff --git a/hermes_cli/cli_subagent_monitor.py b/hermes_cli/cli_subagent_monitor.py
index aaf12014dd8..0498c5d70aa 100644
--- a/hermes_cli/cli_subagent_monitor.py
+++ b/hermes_cli/cli_subagent_monitor.py
@@ -291,17 +291,15 @@ def read_tail(path):
def subagent_tail(row):
- """The child's transcript tail: the gateway's ``subagent.tail`` when it runs the child (as cached
- by the monitor's tick, never fetched here: the detail view calls this every frame), else the
+ """The child's transcript tail: the gateway's ``subagent.tail`` when it runs the child (fetched and
+ filtered by the monitor's tick, never here: the detail view calls this every frame), else the
transcript file this process wrote."""
from hermes_cli.gateway_tools import process_view
view = process_view()
if view is None:
return read_tail(row.get('live_transcript'))
text = view.subagent_tail(row['subagent_id'])
- if text is None:
- return t('cli.subagents.transcript_unavailable')
- return ''.join(c for c in text if c.isprintable() or c in '\n\t')
+ return t('cli.subagents.transcript_unavailable') if text is None else text
def modal_prompt_active(cli):
diff --git a/hermes_cli/gateway_tools.py b/hermes_cli/gateway_tools.py
index b882bb24cba..8fc88b9ef6e 100644
--- a/hermes_cli/gateway_tools.py
+++ b/hermes_cli/gateway_tools.py
@@ -165,6 +165,8 @@ class GatewayProcessView:
result = self.connection.call("subagent.tail", session_id=self.session_id,
subagent_id=subagent_id, timeout=5) or {}
text = result.get("text") if result.get("available") else None
+ if text is not None: # filter once here, not on every repaint of the detail view
+ text = "".join(c for c in text if c.isprintable() or c in "\n\t")
except (GatewayClientError, RuntimeError) as exc:
logger.debug("subagent.tail failed: %s", exc)
text = None