mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
Closes #8933 more fully, extending the per-tool transform_terminal_output hook from #12929 to a generic seam that fires after every tool dispatch. Plugins can rewrite any tool's result string (normalize formats, redact fields, summarize verbose output) without wrapping individual tools. Changes - hermes_cli/plugins.py: add "transform_tool_result" to VALID_HOOKS - model_tools.py: invoke the hook in handle_function_call after post_tool_call (which remains observational); first valid str return replaces the result; fail-open - tests/test_transform_tool_result_hook.py: 9 new tests covering no-op, None return, non-string return, first-match wins, kwargs, hook exception fallback, post_tool_call observation invariant, ordering vs post_tool_call, and an end-to-end real-plugin integration - tests/hermes_cli/test_plugins.py: assert new hook in VALID_HOOKS - tests/test_model_tools.py: extend the hook-call-sequence assertion to include the new hook Design - transform_tool_result runs AFTER post_tool_call so observers always see the original (untransformed) result. This keeps post_tool_call's observational contract. - transform_terminal_output (from #12929) still runs earlier, inside terminal_tool, so plugins can canonicalize BEFORE the 50k truncation drops middle content. Both hooks coexist; they target different layers.
25 KiB
25 KiB