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=[