taolib.symphony.agent.runner#

智能体运行器。

编排单个 Issue 的完整运行流程: 工作区创建 → before_run 钩子 → 启动 app-server → 轮次循环 → 停止 → after_run 钩子。

Classes#

IssueInfo

Issue 信息的协议接口。

RunnerConfig

运行器配置。

AgentRunner

智能体运行器。

Module Contents#

class taolib.symphony.agent.runner.IssueInfo#

Bases: Protocol

Issue 信息的协议接口。

property identifier: str#
property title: str#
property status: str#
model_dump() dict[str, Any]#
class taolib.symphony.agent.runner.RunnerConfig#

运行器配置。

command: str = 'codex'#

启动 app-server 的命令。

max_turns: int = 10#

单次运行最大轮次数。

approval_policy: str = 'never'#

审批策略。

stall_timeout_ms: int = 300000#

停滞检测超时(毫秒)。

before_run: str | None = None#

运行前钩子脚本。

after_run: str | None = None#

运行后钩子脚本。

hook_timeout_ms: int = 30000#

钩子超时(毫秒)。

class taolib.symphony.agent.runner.AgentRunner(transport: taolib.symphony.agent.transport.AgentTransport, config: RunnerConfig | None = None)#

智能体运行器。

编排单个 Issue 的完整运行生命周期: 创建工作区 → 执行 before_run 钩子 → 启动 app-server → 轮次循环 → 停止 app-server → 执行 after_run 钩子。

_transport#
_config#
_client#
property client: taolib.symphony.agent.appserver.AppServerClient#

底层 AppServer 客户端。

async run_attempt(issue: IssueInfo, attempt: int, workspace_path: str, *, build_prompt: collections.abc.Callable[[IssueInfo, int, int], str], check_issue_status: collections.abc.Callable[[IssueInfo], asyncio.Coroutine[Any, Any, str | None]] | None = None, on_event: collections.abc.Callable[[taolib.symphony.agent.events.AppServerEvent], None] | None = None) taolib.symphony.agent.events.TurnResult#

执行一次完整的运行尝试。

流程: 1. 执行 before_run 钩子 2. 启动 app-server 进程 3. 初始化会话 4. 轮次循环(构建提示词 → 运行轮次 → 检查状态) 5. 停止 app-server 6. 执行 after_run 钩子

参数:
  • issue -- Issue 信息。

  • attempt -- 尝试序号(从 0 开始)。

  • workspace_path -- 工作区路径。

  • build_prompt -- 提示词构建回调。

  • check_issue_status -- Issue 状态检查回调(可选)。

  • on_event -- 事件回调(可选)。

返回:

最终轮次结果。