Skip to content

fix: enable runtime final response guards - #56429

Open
romashki-sai wants to merge 1 commit into
NousResearch:mainfrom
romashki-sai:fix/runtime-response-guards
Open

fix: enable runtime final response guards#56429
romashki-sai wants to merge 1 commit into
NousResearch:mainfrom
romashki-sai:fix/runtime-response-guards

Conversation

@romashki-sai

Copy link
Copy Markdown

Summary

  • pass user/chat/channel context into shell hook events
  • allow transform_llm_output shell hooks to return a final response replacement string
  • add parser regression coverage for response_text passthrough

Test Plan

  • python -m pytest tests/agent/test_shell_hooks.py -q
  • python -m pytest /home/hermes/.hermes/triggers/tests -q
  • hermes hooks doctor
  • hermes hooks test transform_llm_output --payload-file /tmp/transform_payload.json

Pass channel and user context into shell hooks and allow transform_llm_output shell hooks to return a final response replacement. Add parser regression coverage for response_text passthrough.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Jul 1, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: LGTM

Enables runtime final response guards and adds transform_llm_output support to shell hooks. Also enriches hook context with sender/chat metadata.

Looks Good

  • Transform hook correctly returns string (not dict) for response replacement
  • Backward-compatible: Optional[Any] return type broadens but doesn't break
  • Clean tests for both passthrough and empty-text cases
  • New context fields (sender_name, chat_id, etc.) are additive

Reviewed by Hermes Agent

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused shell-hook fix. The underlying gap is still present on current main: agent/shell_hooks.py:566-620 does not translate transform_llm_output response_text JSON into the string contract consumed by the final-response hook.

Problems

  • The final-response hunk no longer targets the live dispatch site. Refactor 55b83c3d9 moved it from agent/conversation_loop.py to agent/turn_finalizer.py:380-391; the PR is currently reported dirty by GitHub.
  • tests/agent/test_shell_hooks.py adds parser-only coverage. It does not verify a configured shell hook reaches the current finalizer and replaces final_response.

Suggested changes

  • Salvage the transform-context kwargs into agent/turn_finalizer.py:380-391, using its original_user_message parameter.
  • Add a runtime shell-hook-to-final-response regression test, including the replacement and emitted context.

Automated hermes-sweeper review.

@@ -4411,6 +4423,14 @@ def _stop_spinner():
session_id=agent.session_id or "",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current main moved this live transform_llm_output dispatch to agent/turn_finalizer.py:380-391 in 55b83c3d9; port these kwargs there during salvage, otherwise this hunk does not affect the runtime final-response path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants