refactor(sessions)!: retire the global shared session (#6621)
Co-authored-by: chengyongru <chengyongru.ai@gmail.com>
This commit is contained in:
1 parent
28d73b6942
commit
e6b0aec2a8
77 files changed
+311
-1255
No files matched your search
@@ -28,13 +28,11 @@ from nanobot.security.workspace_access import (
|
||||
build_workspace_scope,
|
||||
reset_workspace_scope,
|
||||
)
|
||||
from nanobot.session.keys import UNIFIED_SESSION_KEY
|
||||
from nanobot.utils.llm_runtime import LLMRuntime
|
||||
|
||||
|
||||
def _make_loop(
|
||||
tmp_path: Path, *, allow_set: bool = False, restricted: bool = False, sandbox: str = "",
|
||||
unified_session: bool = False,
|
||||
) -> AgentLoop:
|
||||
provider = MagicMock()
|
||||
provider.get_default_model.return_value = "test-model"
|
||||
@@ -49,7 +47,6 @@ def _make_loop(
|
||||
model="test-model",
|
||||
tools_config=tools_config,
|
||||
restrict_to_workspace=restricted,
|
||||
unified_session=unified_session,
|
||||
)
|
||||
|
||||
|
||||
@@ -505,7 +502,7 @@ async def test_followup_only_joins_matching_tool_scope(tmp_path: Path, same_scop
|
||||
project = tmp_path / "project"
|
||||
project.mkdir()
|
||||
(project / "marker.txt").write_text("active project", encoding="utf-8")
|
||||
loop = _make_loop(tmp_path / "agent", unified_session=True)
|
||||
loop = _make_loop(tmp_path / "agent")
|
||||
loop.provider.generation = GenerationSettings()
|
||||
loop.provider.chat_stream_with_retry = AsyncMock(side_effect=[
|
||||
LLMResponse(content=None, tool_calls=[
|
||||
@@ -513,7 +510,7 @@ async def test_followup_only_joins_matching_tool_scope(tmp_path: Path, same_scop
|
||||
]),
|
||||
LLMResponse(content="done"),
|
||||
])
|
||||
session = await loop.sessions.state.get(UNIFIED_SESSION_KEY)
|
||||
session = await loop.sessions.state.get("websocket:chat")
|
||||
session.metadata["workspace_scope"] = {"project_path": str(project), "access_mode": "restricted"}
|
||||
session.add_message("user", "Start")
|
||||
await loop.sessions.state.prepare_input(session)
|
||||
|
||||
@@ -32,7 +32,6 @@ def _make_mock_loop(**overrides):
|
||||
loop.model_preset = None
|
||||
loop.model_presets = {}
|
||||
loop._concurrency_gate = None
|
||||
loop._unified_session = False
|
||||
loop._extra_hooks = []
|
||||
loop.set_runtime_model.side_effect = lambda value: setattr(loop, "model", value)
|
||||
loop.set_runtime_max_iterations.side_effect = lambda value: setattr(loop, "max_iterations", value)
|
||||
|
||||
Reference in new issue
Block a user