refactor(agent): defer transcript assembly to runner (#5608)

* refactor(agent): defer transcript assembly to runner

Keep persisted history and the fresh turn as explicit inputs until the Runner assembles the provider transcript. Preserve ContextBuilder and direct AgentRunner compatibility while making the save boundary structural.

Refs NAN-81.

* fix(providers): preserve mixed adjacent user content
This commit is contained in:
chengyongru
2026-08-31 00:06:15 +08:00
committed by GitHub
parent d019658501
commit 6cd7063682
19 changed files with 355 additions and 113 deletions
+3 -2
View File
@@ -5,6 +5,7 @@ from unittest.mock import AsyncMock, MagicMock
import pytest
from nanobot.agent.context import TranscriptInput
from nanobot.agent.loop import AgentLoop
from nanobot.agent.tools.context import (
RequestContext,
@@ -133,7 +134,7 @@ async def test_loop_binds_request_context_for_tool_execution(tmp_path: Path) ->
metadata = {"slack": {"thread_ts": "111.222", "channel_type": "channel"}}
runtime = loop.llm_runtime()
await loop._run_agent_loop(
[],
TranscriptInput(history=[], current_message=None),
runtime=runtime,
request_context=RequestContext(
channel="slack",
@@ -234,7 +235,7 @@ async def test_agent_loop_restores_outer_request_context_after_runner_exception(
try:
with pytest.raises(RuntimeError, match="runner failed"):
await loop._run_agent_loop(
[],
TranscriptInput(history=[], current_message=None),
runtime=runtime,
request_context=RequestContext(
channel="slack",