refactor(session): unify model and display history storage (#6336)

* refactor(session): persist display history in SQLite

* fix(session): preserve new fork activity timestamps

* test(agent): use SQLite-owned model failure recovery fixture

* test(agent): isolate session slash routing from loop shutdown

Exercise the real inbound dispatcher and await its session worker. Keep response deadlines and behavioral assertions, while leaving full SQLite cleanup to the existing async fixture rather than an unrelated two-second shutdown deadline.

* fix(webui): admit direct deliveries to display history

* docs: clarify session history migration guidance
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-21 16:13:59 +08:00
1 parent d617b723aa
commit b32b1327ce
50 files changed
+2123 -3235

No files matched your search

+7 -9
View File
@@ -5,7 +5,6 @@ from unittest.mock import AsyncMock, MagicMock
import pytest
from agent.session_helpers import stop_loop
from nanobot.agent.loop import AgentLoop
from nanobot.bus.events import InboundMessage
from nanobot.bus.queue import MessageBus
@@ -89,15 +88,14 @@ async def test_session_message_text_is_not_dispatched_as_a_slash_command(
loop: AgentLoop,
) -> None:
loop.sessions.save(loop.sessions.get_or_create("telegram:target"))
task = asyncio.create_task(loop.run())
try:
await loop.bus.publish_inbound(_message("/stop"))
response = await asyncio.wait_for(loop.bus.consume_outbound(), timeout=2)
await loop._dispatch_inbound(_message("/stop"))
await asyncio.wait_for(
asyncio.gather(*loop._active_tasks["telegram:target"]), timeout=2,
)
response = await asyncio.wait_for(loop.bus.consume_outbound(), timeout=2)
assert response.content == "Reviewed"
loop.provider.chat_stream_with_retry.assert_awaited_once()
finally:
await stop_loop(loop, task, timeout=2)
assert response.content == "Reviewed"
loop.provider.chat_stream_with_retry.assert_awaited_once()
async def test_path_followup_reaches_running_turn(loop: AgentLoop) -> None: