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

+4 -4
View File
@@ -257,7 +257,7 @@ async def test_compact_during_active_turn_waits_for_the_session_lock(loop, comma
)
lock = loop._get_session_lock(key)
async with lock:
await loop._dispatch_command_inline(msg, key, msg.content, loop.commands.dispatch)
await loop._dispatch_command_inline(msg, msg.content, loop.commands.dispatch)
tasks = list(loop._active_tasks[key])
assert len(tasks) == 1
await asyncio.sleep(0)
@@ -285,7 +285,7 @@ async def test_stop_completes_a_compact_command_waiting_for_the_session_lock(loo
completions = []
loop.bus.subscribe(completions.append, TurnCompleted)
async with loop._get_session_lock(key):
await loop._dispatch_command_inline(msg, key, msg.content, loop.commands.dispatch)
await loop._dispatch_command_inline(msg, msg.content, loop.commands.dispatch)
reply = await cmd_stop(CommandContext(
msg=msg, session=None, key=key, raw="/stop", loop=loop,
))
@@ -330,7 +330,7 @@ async def test_compact_is_a_fifo_barrier_during_an_active_turn(loop, command_tex
channel="cli", sender_id="u", chat_id="test", content="before compaction",
)))
command = InboundMessage(channel="cli", sender_id="u", chat_id="test", content=command_text)
await loop._dispatch_command_inline(command, key, command.content, loop.commands.dispatch)
await loop._dispatch_command_inline(command, command.content, loop.commands.dispatch)
(await loop._enqueue_session_message(InboundMessage(
channel="cli", sender_id="u", chat_id="test", content="after compaction",
)))
@@ -375,7 +375,7 @@ async def test_stop_completes_compact_queued_behind_an_active_turn(loop, command
channel="websocket", sender_id="u", chat_id="test", content=command_text,
metadata={"webui_turn_id": "queued-compact"},
)
await loop._dispatch_command_inline(command, key, command.content, loop.commands.dispatch)
await loop._dispatch_command_inline(command, command.content, loop.commands.dispatch)
await cmd_stop(CommandContext(msg=command, session=None, key=key, raw="/stop", loop=loop))
assert task.cancelled()