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
+24 -9
View File
@@ -214,7 +214,12 @@ class WorkflowBrain(BaseBrain):
self._cfg = cfg
self._runtime = runtime
self._store = DynamicVariableStore.from_config(cfg)
self._tools = ToolExecutor(self._store, client_tools=runtime.client_tools)
self._tools = (
runtime.tool_executor_factory(self._store)
if runtime.tool_executor_factory is not None
else ToolExecutor(self._store, client_tools=runtime.client_tools)
)
self._tools.set_client_tools(runtime.client_tools)
self._actions = ActionRunner(
self._tools,
is_session_ending=lambda: runtime.call_end.ending,
@@ -934,18 +939,28 @@ class WorkflowBrain(BaseBrain):
"""Build one platform-owned tool scoped to the active Agent node."""
kind = system_tool_kind(tool.definition or {})
if kind == "update_state":
return self._workflow_update_state_tool(
schema = self._workflow_update_state_tool(
tool,
node_id,
state_variable_names=state_variable_names,
)
if kind == "skip_turn":
return self._workflow_skip_turn_tool(tool)
if kind == "request_human_handoff":
return self._workflow_handoff_tool(tool, node_id)
if kind == "end_conversation":
return self._workflow_end_conversation_tool(tool, node_id)
raise ValueError(f"系统工具 {tool.id} 缺少有效 kind")
elif kind == "skip_turn":
schema = self._workflow_skip_turn_tool(tool)
elif kind == "request_human_handoff":
schema = self._workflow_handoff_tool(tool, node_id)
elif kind == "end_conversation":
schema = self._workflow_end_conversation_tool(tool, node_id)
else:
raise ValueError(f"系统工具 {tool.id} 缺少有效 kind")
runtime = self._require_runtime()
if runtime.tool_executor_factory is None:
return schema
async def mock_system_tool(args, _flow_manager):
return await self._tools.execute(tool, dict(args or {}))
return replace(schema, handler=mock_system_tool)
def _workflow_update_state_tool(
self,