mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-29 01:31:41 +00:00
fix(gateway): avoid cross-user mirror writes in per-user group sessions
This commit is contained in:
parent
cd2aee36ca
commit
fd474d0f00
4 changed files with 168 additions and 12 deletions
|
|
@ -167,6 +167,39 @@ class TestSendMessageTool:
|
|||
media_files=[],
|
||||
)
|
||||
|
||||
def test_mirror_receives_current_session_user_id(self):
|
||||
config, _telegram_cfg = _make_config()
|
||||
|
||||
with patch("gateway.config.load_gateway_config", return_value=config), \
|
||||
patch("tools.interrupt.is_interrupted", return_value=False), \
|
||||
patch("model_tools._run_async", side_effect=_run_async_immediately), \
|
||||
patch("tools.send_message_tool._send_to_platform", new=AsyncMock(return_value={"success": True})), \
|
||||
patch("gateway.session_context.get_session_env") as get_session_env_mock, \
|
||||
patch("gateway.mirror.mirror_to_session", return_value=True) as mirror_mock:
|
||||
get_session_env_mock.side_effect = lambda name, default="": {
|
||||
"HERMES_SESSION_PLATFORM": "telegram",
|
||||
"HERMES_SESSION_USER_ID": "user-123",
|
||||
}.get(name, default)
|
||||
result = json.loads(
|
||||
send_message_tool(
|
||||
{
|
||||
"action": "send",
|
||||
"target": "telegram:12345",
|
||||
"message": "hello",
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
assert result["success"] is True
|
||||
mirror_mock.assert_called_once_with(
|
||||
"telegram",
|
||||
"12345",
|
||||
"hello",
|
||||
source_label="telegram",
|
||||
thread_id=None,
|
||||
user_id="user-123",
|
||||
)
|
||||
|
||||
def test_top_level_send_failure_redacts_query_token(self):
|
||||
config, _telegram_cfg = _make_config()
|
||||
leaked = "very-secret-query-token-123456"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue