From 974d94683a71b28456eef7313f01ad33fb030288 Mon Sep 17 00:00:00 2001 From: Offending Commit Date: Fri, 30 Oct 2026 09:20:56 -0500 Subject: [PATCH] fix(hooks): read the user_message Hermes passes to pre_llm_call The hint hook looked for user_text, prompt, message, content and messages, but Hermes calls pre_llm_call with user_message and conversation_history. The hook found no text, returned None on every turn, and logged zero hints across all six public Discord profiles. Its tests passed because they used the message= alias. Add user_message first and a test that calls the hook with the exact keyword set Hermes v0.22.5 sends. Claude-Session: https://claude.ai/code/session_01B6XeATwx1VYhtEMDunQWD3 --- hooks.py | 3 ++- tests/test_hooks.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hooks.py b/hooks.py index 438fb65..b4e11c4 100644 --- a/hooks.py +++ b/hooks.py @@ -16,7 +16,8 @@ def _latest_user_text(**kwargs: Any) -> str: - for key in ("user_text", "prompt", "message", "content"): + # Hermes passes the current turn as user_message; the other keys are older aliases. + for key in ("user_message", "user_text", "prompt", "message", "content"): value = kwargs.get(key) if isinstance(value, str) and value.strip(): return value diff --git a/tests/test_hooks.py b/tests/test_hooks.py index 4acb7a1..dac7e7f 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -13,6 +13,24 @@ class HookTests(unittest.TestCase): + def test_injects_hint_from_the_kwargs_hermes_passes(self) -> None: + # The exact keyword set Hermes v0.22.5 agent/turn_context.py _collect_pre_llm_call_context sends. + result = hooks.inject_discord_read_hint( + session_id="s", + task_id="t", + turn_id="u", + user_message="Check https://discord.com/channels/111/222/333", + conversation_history=[{"role": "user", "content": "earlier"}], + is_first_turn=False, + model="m", + platform="discord", + parent_session_id="", + sender_id="1", + ) + + self.assertIsNotNone(result) + self.assertIn("https://discord.com/channels/111/222/333", result["context"]) + def test_injects_hint_for_discord_link(self) -> None: result = hooks.inject_discord_read_hint( messages=[