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

+5 -2
View File
@@ -1007,7 +1007,7 @@ class AgentLoop:
if session is None:
return NO_EVENTS
return self.turn_delivery_factory.session_events(
session_key, session.metadata,
session_key, session.metadata, generation=session.generation,
)
def _remember_session_route(
@@ -2061,7 +2061,7 @@ class AgentLoop:
else:
ctx.session = await self.sessions.state.get(ctx.session_key)
session = ctx.session
ctx.delivery.bind_session_generation(session.generation)
await ctx.delivery.bind_session_generation(session.generation)
ctx.ephemeral = ctx.ephemeral or not session.policy.persist
tools = ctx.tools if ctx.tools is not None else self.tools
if session.policy.disabled_tools:
@@ -2141,6 +2141,9 @@ class AgentLoop:
ctx.turn_scopes.append(GoalInputScope(ctx.msg))
if result is not None:
ctx.outbound = result
if cmd_ctx.raw.lower() == "/new":
current = await self.sessions.state.get_header(ctx.session_key)
await ctx.delivery.bind_session_generation(current.generation)
# Shortcut commands skip BUILD and SAVE, so we must persist the
# turn here so WebUI history hydration after turn_end sees the
# message. Mark messages with _command so get_history can filter