feat(tools): add terminal output transform hook#10155
Closed
sjz-ks wants to merge 1 commit into
Closed
Conversation
a471bff to
796db08
Compare
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a minimal plugin hook for terminal foreground output:
transform_terminal_output.This gives plugins a narrow canonicalization seam for terminal
output: strbefore the default50ktruncation runs, without changing the existingpost_tool_callcontract or exposing live mutable result objects.The hook is intentionally scoped to the foreground
terminal()path only, is fail-open, and only accepts string replacements.This hook is intentionally limited to string-level canonicalization and does not provide a structured persistence channel; plugins that want to retain extra artifacts must do so via their own side effects and describe any follow-up access path in the returned text.
This keeps the change focused on the concrete issue: allowing plugins to summarize or otherwise shrink oversized terminal output before Hermes applies its normal truncation/redaction pipeline.
Related Issue
Closes #8933
Type of Change
Changes Made
transform_terminal_outputtoVALID_HOOKSinhermes_cli/plugins.pytools/terminal_tool.pycommand,output,returncode,task_id, andenv_typeNonemeans no-opstrreturn replaces the output50ktruncation,strip_ansi,redact_sensitive_text,exit_code_meaning, and normal JSON result assemblytests/hermes_cli/test_plugins.pytests/tools/test_terminal_output_transform_hook.pytools/terminal_tool.pycomments and updated the plugin hooks tip inhermes_cli/tips.pyHow to Test
source venv/bin/activatetransform_terminal_outputterminal()command with very large outputChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Manual TUI verification screenshots attached.
Before: without the plugin transform, the middleERROR_KEYWORDis lost after the default truncation path.After: withtransform_terminal_output, the plugin extracts the middle error keyword before truncation and returns a compact canonical preview that preserves the keyword value.The demo output was constructed so the keyword appears only in the middle of a large terminal result, isolating the value of the new hook from the default head/tail truncation behavior.
Targeted tests passed:
python -m pytest tests/hermes_cli/test_plugins.py -q→30 passedpython -m pytest tests/tools/test_terminal_output_transform_hook.py -q→9 passedpytest tests/ -vstill shows existing upstream failures, but the same stable failing subset reproduces onorigin/main, so this PR does not appear to introduce any new failures or regressions.codex reviewalso did not find any discrete, actionable issues relative toupstream/main; the new terminal-output hook matches the existing plugin hook patterns, and the focused hook/terminal tests pass.