refactor(sessions): discover target handles through search (#6315)

Co-authored-by: chengyongru <chengyongru.ai@gmail.com>
This commit is contained in:
davidandchengyongru authored and GitHub committed 2026-10-29 10:38:06 +08:00
1 parent acc3750c28
commit b6d9009bb4
6 files changed
+93 -116

No files matched your search

-24
View File
@@ -1,5 +1,4 @@
import asyncio
import json
from pathlib import Path
from typing import Callable
from unittest.mock import patch
@@ -8,7 +7,6 @@ import pytest
from nanobot.agent.tools.context import RequestContext, request_context
from nanobot.agent.tools.session_messages import (
ListSessionsTool,
SendSessionMessageTool,
SessionMessageError,
)
@@ -70,28 +68,6 @@ def test_config_and_tool_schema_keep_only_the_basic_reply_contract(
assert (timeout["minimum"], timeout["maximum"]) == (5, 60)
@pytest.mark.asyncio
async def test_list_sessions_includes_all_persisted_channels_except_current(
tmp_path: Path,
) -> None:
sessions = SessionManager(tmp_path)
_persist(sessions, "websocket:current", "telegram:other", "slack:team")
tool = ListSessionsTool(sessions)
expected = {
f"@{_handle(sessions, 'telegram:other').name}",
f"@{_handle(sessions, 'slack:team').name}",
}
with request_context(RequestContext(
channel="websocket",
chat_id="current",
session_key="websocket:current",
)):
result = json.loads(await tool.execute())
assert set(result) == expected
@pytest.mark.asyncio
async def test_send_publishes_user_input_to_the_existing_target(
tmp_path: Path,