feat(gateway): add per-platform terminal_progress knob to keep terminal commands compact in chat - #42638
feat(gateway): add per-platform terminal_progress knob to keep terminal commands compact in chat#42638GodsBoy wants to merge 3 commits into
Conversation
…de_block)
Terminal-command tool progress on markdown-capable platforms (Telegram,
WhatsApp, Slack, Feishu, Matrix, Weixin) currently renders the full shell
command as a bare fenced code block. There is no way to keep it compact
without turning off all tool progress.
Add a display.terminal_progress setting with values compact and code_block
(default code_block), resolved through the existing per-platform display
resolver. When set to compact, terminal progress falls back to the short
truncated `terminal: "..."` preview that every other tool already uses, so
the full command is not posted to the chat. Only the terminal tool is
affected; other breadcrumbs (search_files, read_file, patch, todo) are
unchanged, and the default preserves current behavior.
Regression tests drive the real {"command": ...} path so they exercise the
code-block branch (the existing truncation tests pass {} args and never did).
…act knob Code review found that terminal_progress=compact only suppressed the fenced block in all/new modes. In verbose mode the full command was still serialized through the args branch (tool_preview_length defaults to 0 in verbose), so the command could still reach the chat. Render the truncated terminal preview with a 40-char cap in verbose mode too when the knob is compact, matching the all/new path. Strengthen the verbose compact test to assert the truncated preview is present and the command tail is absent (it previously passed only by incidental truncation), harden the all/new compact assertion against partial-token leaks, and add a normalise edge test for non-string scalar values.
|
Thanks for this PR — the
Clean implementation. 👍 |
|
@teknium1 reopening this. The live repro shows the terminal progress leak is still present on a deployed Telegram gateway. Evidence from the fresh smoke:
The earlier close was based on one live check that appeared compact, but this new screenshot proves the bug still reproduces. Reopening the issue and PR so #42638, or an equivalent upstream fix, can be considered again. |
|
Heads-up on the red The 8 failures are all in This PR's own changes are limited to |
Resolve gateway/run.py conflict with NousResearch#42634, which split the terminal fenced block into a full (verbose) and a single-line capped (non-verbose) variant. Keep the terminal_progress knob gate on the build condition so compact still falls through to the truncated preview in both modes, and adopt the _code_block_full / _code_block_short variables for rendering. Update test_terminal_progress_explicit_code_block_still_renders to assert the capped first-line fence in non-verbose mode rather than the full command.
|
Update: I also merged latest |
|
Closing this for now after retesting current main without the local patch. The remaining live issue I was seeing on Telegram is resolved by #42729: terminal progress in non-verbose mode now keeps the fenced code-block presentation but caps it to a compact single-line preview. That covers my deployed gateway configuration, since I am not running verbose tool progress. The per-platform compact/code_block knob in this PR may still be useful as a preference later, but it is no longer needed for the original regression I was trying to fix. Thanks for the follow-up fix. |
What does this PR do?
On markdown-capable messaging platforms (Telegram, WhatsApp, Slack, Feishu, Matrix, Weixin), gateway tool progress for the
terminaltool renders the full, untruncated shell command as a bare fenced code block. There is currently no way to keep it compact without turning off all tool progress, which also removes useful breadcrumbs likesearch_files,read_file,patch, andtodo.This is a regression:
terminal: "..."preview.Rather than revert #42576 again (which would just restart the back and forth), this PR makes the behavior configurable per platform. A new
display.terminal_progresssetting takescompactorcode_block:code_block(default) keeps feat(gateway): render terminal commands as bare fenced code blocks in chat #42576 behavior. Nothing changes out of the box, and feat(gateway): render terminal commands as bare fenced code blocks in chat #42576's existing test stays green.compactfalls back to the short truncatedterminal: "..."preview, so the full command is not posted to the chat, while other breadcrumbs stay visible.The setting is resolved through the existing per-platform display resolver, so a deployment can set it globally (
display.terminal_progress) or per platform (display.platforms.telegram.terminal_progress). Only the terminal tool is affected.Related Issue
Fixes #42637
Type of Change
Changes Made
gateway/display_config.py: addterminal_progressto_GLOBAL_DEFAULTS(defaultcode_block) and a_normalisebranch that lower-cases the value and falls back tocode_blockfor anything outside{compact, code_block}.OVERRIDEABLE_KEYSis derived from_GLOBAL_DEFAULTS, so the key becomes per-platform overrideable automatically.gateway/run.py: resolveterminal_progressonce per source in the existing display-settings setup block, then gate the fenced_code_blockbuild onterminal_progress == "code_block". Incompact, the callback falls through to the existing truncated preview inall/newmodes, and the verbose branch also renders the truncated preview (with a 40-char cap) so the full command is not posted in verbose mode either.cli-config.yaml.example: document the newterminal_progresssetting with a per-platform override example.tests/gateway/test_display_config.py: addTestTerminalProgresscovering default, global, per-platform override precedence, case-insensitivity, unknown and non-string scalar normalisation, andOVERRIDEABLE_KEYSmembership.tests/gateway/test_run_progress_topics.py: add run-level regression tests that drive the real{"command": ...}path (the existing truncation tests pass{}args and never reach the code-block branch). They covercompactinallandverbosemodes (no fence, truncated preview present, command tail absent) and an explicitcode_blockrun that still fences. The existingtest_terminal_progress_renders_fenced_code_blockis left untouched as the default-preserved guard.How to Test
display.platforms.telegram.tool_progress: all.terminalcommand. With noterminal_progressset (default), the full command renders as a fenced code block, same as today.display.platforms.telegram.terminal_progress: compactand run aterminalcommand again. Now the progress shows the short truncatedterminal: "..."preview, and other breadcrumbs (search_files,read_file,patch,todo) are unchanged.All 74 tests pass. The new compact tests were verified to fail when the gate is removed, so they genuinely guard the leak path (including the verbose path).
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qfor the affected modules and all tests passDocumentation & Housekeeping
cli-config.yaml.examplebecause I added a config keyScreenshots / Logs
Before this PR, a
terminalprogress bubble on Telegram renders the full multi-line command as a fenced code block, including the working directory:With
display.platforms.telegram.terminal_progress: compact, the same command renders as the shortterminal: "..."preview instead.