fix(gateway): stop terminal progress from posting the full command to messaging chats#41950
Conversation
|
Code Review: Clean — no issues found. Reviewed the full diff across all 8 files. The security posture is sound:
One minor note for the author: tools not in |
0820fa2 to
940375e
Compare
|
Update: simplified to a minimal revert. After more live testing, the right fix is just to undo #41215's bash-block rendering and restore the short truncated terminal preview that every tool already used. The truncated previews themselves were never the problem, only the full untruncated command in a fenced block was. The earlier label/opt-in approach was over-engineered for this. The current PR is ~28 lines reverted in |
940375e to
2ca8977
Compare
… messaging chats NousResearch#41215 rendered a terminal tool call as a native ```bash fenced block on markdown platforms (Telegram, WhatsApp, Slack, and others), showing the full command with no truncation, in both all/new and verbose modes. That posted complete shell commands (heredocs, internal paths, destructive commands) into the chat before the final answer, visible to everyone in it. This restores the prior behavior: terminal progress shows the short, truncated preview line that every other tool already uses, capped at tool_preview_length. The supports_code_blocks capability flag is left in place for future use. CLI/TUI rendering is a separate path and was unaffected. Adds a regression test asserting terminal progress renders as a truncated preview, not a fenced bash block, even on a markdown-capable gateway. Fixes NousResearch#41955
2ca8977 to
a18d7d4
Compare
|
I wonder if there's a way we could make this a config option for the owner of the gateway, rather than a revert. as someone who uses discord for ease of communicating with my personal bot for getting updates/tasks, I actually found this update incredibly valuable for being able to see exactly what my bot is going to do on my phone when I don't have terminal access, and would be sad to see it reverted. |
At least in Telegram, the merging of #41215 is causing a mess, as Telegram is not rendering the Markdown code boxes correctly, as you can also see in the screenshots above. So at the moment it is a bug that should be fixed asap, not (yet?) a feature that could be included as an opt-in... |
… chat (#42576) Terminal tool progress on markdown-capable gateways (Telegram, Slack, Discord, WhatsApp, Matrix, Weixin, Feishu) renders the full command in a fenced code block again, in all/new AND verbose modes — gated on the adapter's supports_code_blocks capability. Plain-text platforms keep the short truncated preview. No language tag is emitted: Slack mrkdwn renders a '```bash' fence with 'bash' as a literal first code line, so a bare '```' fence is used, which renders correctly on every platform that supports blocks. This restores the #41215 feature (removed in #41950 due to the command showing in group chats) as the default. For a personal assistant the command display is desired; the group-chat concern is a preference, not a vulnerability.
… chat (NousResearch#42576) Terminal tool progress on markdown-capable gateways (Telegram, Slack, Discord, WhatsApp, Matrix, Weixin, Feishu) renders the full command in a fenced code block again, in all/new AND verbose modes — gated on the adapter's supports_code_blocks capability. Plain-text platforms keep the short truncated preview. No language tag is emitted: Slack mrkdwn renders a '```bash' fence with 'bash' as a literal first code line, so a bare '```' fence is used, which renders correctly on every platform that supports blocks. This restores the NousResearch#41215 feature (removed in NousResearch#41950 due to the command showing in group chats) as the default. For a personal assistant the command display is desired; the group-chat concern is a preference, not a vulnerability.
… chat (NousResearch#42576) Terminal tool progress on markdown-capable gateways (Telegram, Slack, Discord, WhatsApp, Matrix, Weixin, Feishu) renders the full command in a fenced code block again, in all/new AND verbose modes — gated on the adapter's supports_code_blocks capability. Plain-text platforms keep the short truncated preview. No language tag is emitted: Slack mrkdwn renders a '```bash' fence with 'bash' as a literal first code line, so a bare '```' fence is used, which renders correctly on every platform that supports blocks. This restores the NousResearch#41215 feature (removed in NousResearch#41950 due to the command showing in group chats) as the default. For a personal assistant the command display is desired; the group-chat concern is a preference, not a vulnerability.
… chat (NousResearch#42576) Terminal tool progress on markdown-capable gateways (Telegram, Slack, Discord, WhatsApp, Matrix, Weixin, Feishu) renders the full command in a fenced code block again, in all/new AND verbose modes — gated on the adapter's supports_code_blocks capability. Plain-text platforms keep the short truncated preview. No language tag is emitted: Slack mrkdwn renders a '```bash' fence with 'bash' as a literal first code line, so a bare '```' fence is used, which renders correctly on every platform that supports blocks. This restores the NousResearch#41215 feature (removed in NousResearch#41950 due to the command showing in group chats) as the default. For a personal assistant the command display is desired; the group-chat concern is a preference, not a vulnerability.
What does this PR do?
Since #41215 (render terminal tool calls as native bash code blocks on markdown platforms), terminal progress on messaging gateways (WhatsApp, Telegram, Slack, and others) rendered the full command as an untruncated fenced bash block, before the final answer, in both
all/newandverbosemodes. That posted complete shell commands (internal paths, systemctl restarts, rm -rf, and similar) into the chat, visible to everyone in it.This restores the prior behavior: terminal progress shows the short, truncated preview line that every other tool already uses (
terminal: "set -e printf 'node: '..."), capped attool_preview_length. Thesupports_code_blockscapability flag is retained for future markdown-aware features; its comment is updated to record that tool progress deliberately no longer renders commands as bash blocks. CLI and TUI rendering is a separate path and was unaffected.To be clear about scope: the short previews are fine and stay. Lines like
search_files: "manifest.yaml",read_file: "/path/...", andtodo: "updating 2 task(s)"are useful context. The bug was specifically the full, untruncated terminal command reaching the chat as a bash block.Related Issue
Fixes #41955
This reverts the rendering change from #41215 (which introduced the leak) while leaving the
supports_code_blockscapability in place. Related: #7161 (quiet gateway progress by default), #23506 (hide memory tool progress).Type of Change
Changes Made
gateway/run.py: reverse-apply feat(gateway): render terminal tool calls as native bash code blocks on markdown platforms #41215'sprogress_callbackhunk so terminal (and every tool) renders the short truncated preview again, not a ```bash block. Dedup,new-mode gating, `verbose` handling, and interrupt suppression are unchanged.gateway/platforms/base.py: update thesupports_code_blockscomment so it no longer advertises rendering a terminal command as a bash block, and notes the deliberate removal.supports_code_blocks) gateway, in bothallandverbosemodes.How to Test
Set
display.tool_progress: alland message the gateway (Telegram or WhatsApp) with a task that runs a shell command.terminal: "<command>...", like every other tool.Run the tests:
Checklist
Code
fix(gateway): ...)tests/gateway/) and they passDocumentation & Housekeeping
cli-config.yaml.examplechanges (no new keys)CONTRIBUTING.md/AGENTS.mdScreenshots / Logs
Live repro on a messaging gateway showing the full terminal command appearing in chat as a fenced bash block: