Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agent/agent_runtime_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,7 @@ def invoke_tool(agent, function_name: str, function_args: dict, effective_task_i
from hermes_cli.plugins import get_pre_tool_call_block_message
block_message = get_pre_tool_call_block_message(
function_name, function_args, task_id=effective_task_id or "",
session_id=agent.session_id or "",
)
except Exception:
pass
Expand Down
2 changes: 2 additions & 0 deletions agent/tool_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def execute_tool_calls_concurrent(agent, assistant_message, messages: list, effe
from hermes_cli.plugins import get_pre_tool_call_block_message
block_message = get_pre_tool_call_block_message(
function_name, function_args, task_id=effective_task_id or "",
session_id=agent.session_id or "",
)
except Exception:
block_message = None
Expand Down Expand Up @@ -589,6 +590,7 @@ def execute_tool_calls_sequential(agent, assistant_message, messages: list, effe
from hermes_cli.plugins import get_pre_tool_call_block_message
_block_msg = get_pre_tool_call_block_message(
function_name, function_args, task_id=effective_task_id or "",
session_id=agent.session_id or "",
)
except Exception:
pass
Expand Down
32 changes: 32 additions & 0 deletions tests/hermes_cli/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,38 @@ def test_first_valid_block_wins(self, monkeypatch):
)
assert get_pre_tool_call_block_message("terminal", {}) == "first blocker"

def test_session_id_forwarded_to_hook(self, monkeypatch):
"""Verify session_id kwarg reaches the plugin hook (regression test)."""
captured_kwargs = {}

def _capture_hook(hook_name, **kwargs):
captured_kwargs.update(kwargs)
return []

monkeypatch.setattr(
"hermes_cli.plugins.invoke_hook",
_capture_hook,
)
get_pre_tool_call_block_message(
"terminal", {}, task_id="t1", session_id="sess-42",
)
assert captured_kwargs.get("session_id") == "sess-42"

def test_session_id_defaults_to_empty_string(self, monkeypatch):
"""When session_id is omitted, hook receives empty string default."""
captured_kwargs = {}

def _capture_hook(hook_name, **kwargs):
captured_kwargs.update(kwargs)
return []

monkeypatch.setattr(
"hermes_cli.plugins.invoke_hook",
_capture_hook,
)
get_pre_tool_call_block_message("todo", {}, task_id="t1")
assert captured_kwargs.get("session_id") == ""


class TestThreadToolWhitelist:
"""Tests for the thread-local tool whitelist used by background review forks."""
Expand Down
Loading