refactor(sessions)!: retire the global shared session (#6621)

Co-authored-by: chengyongru <chengyongru.ai@gmail.com>
This commit is contained in:
Xubin Renandchengyongru authored and GitHub committed 2026-11-12 09:55:55 +08:00
1 parent 28d73b6942
commit e6b0aec2a8
77 files changed
+311 -1255

No files matched your search

+1 -22
View File
@@ -18,8 +18,7 @@ from nanobot.bus.events import (
)
from nanobot.bus.queue import MessageBus
from nanobot.providers.base import GenerationSettings, LLMResponse, ToolCallRequest
from nanobot.runtime_context import RuntimeContextBlock, public_history_message
from nanobot.session.keys import UNIFIED_SESSION_KEY
from nanobot.runtime_context import RuntimeContextBlock
from nanobot.session.manager import SessionPolicy
from nanobot.webui.temporary_chats import WebUITemporaryChats
from nanobot.webui.workspaces import WebUIWorkspaceController
@@ -269,26 +268,6 @@ async def test_session_worker_errors_keep_private_content_out_of_logs(
assert secret not in str([r["message"] for r in records])
@pytest.mark.asyncio
async def test_transient_session_stays_outside_unified_session(tmp_path) -> None:
loop = _loop(tmp_path, ["private answer"], unified_session=True)
durable = loop.sessions.get_or_create(UNIFIED_SESSION_KEY)
durable.add_message("user", "durable question")
loop.sessions.save(durable)
key = "websocket:transient-unified"
await loop.sessions.state.register_transient(key)
await run_session(loop, _message(key, "private question"))
transient = await loop.sessions.state.get(key)
assert [public_history_message(message)["content"] for message in transient.messages] == [
"private question",
"private answer",
]
assert [message["content"] for message in durable.messages] == ["durable question"]
assert loop.sessions.read_session_file(key) is None
@pytest.mark.asyncio
async def test_missing_required_session_cannot_fall_back_to_disk(tmp_path) -> None:
loop = _loop(tmp_path, [])