feat: add persisted batch text testing

This commit is contained in:
Xin Wang
2026-08-10 13:49:24 +08:00
parent 5b8b9fd097
commit 19e8c8c108
27 changed files with 3855 additions and 1450 deletions
+23 -8
View File
@@ -103,6 +103,8 @@ class PromptBrain(BaseBrain):
async def setup(self, cfg: AssistantConfig, runtime: BrainRuntime) -> None:
self._runtime = runtime
if runtime.tool_executor_factory is not None:
self._tools = runtime.tool_executor_factory(self._store)
self._tools.set_client_tools(runtime.client_tools)
self._actions = ActionRunner(
self._tools,
@@ -651,14 +653,27 @@ class PromptBrain(BaseBrain):
if not kind:
raise ValueError(f"系统工具 {tool.id} 缺少有效 kind")
if kind == "end_conversation":
return self._make_end_call_tool(tool, runtime)
if kind == "update_state":
return self._make_update_state_tool(tool, runtime)
if kind == "skip_turn":
return self._make_skip_turn_tool(tool)
if kind == "request_human_handoff":
return self._make_handoff_tool(tool, runtime)
raise ValueError(f"未知系统工具: {kind}")
schema, handler = self._make_end_call_tool(tool, runtime)
elif kind == "update_state":
schema, handler = self._make_update_state_tool(tool, runtime)
elif kind == "skip_turn":
schema, handler = self._make_skip_turn_tool(tool)
elif kind == "request_human_handoff":
schema, handler = self._make_handoff_tool(tool, runtime)
else:
raise ValueError(f"未知系统工具: {kind}")
if runtime.tool_executor_factory is None:
return schema, handler
async def mock_system_tool(params: FunctionCallParams) -> None:
result = await self._tools.execute(
tool,
dict(params.arguments or {}),
)
await params.result_callback(result)
return schema, mock_system_tool
def _make_update_state_tool(self, tool, runtime: BrainRuntime):
"""更新已声明的动态变量(会话状态),并让模型继续当前回答。"""