agent-fleet/openspec/changes/dual-execution-model/proposal.md
Zer4tul e39a16498c feat: dual execution model (SSH CLI + HTTP pull)
- ExecutionMode enum: SshCli (orchestrator dispatches) | HttpPull (agent pulls)
- SSH CLI executor: spawn remote agents via ssh + CLI template
- Local subprocess as SSH special case (localhost)
- HostConfig with capability matching and load-based selection
- Dispatch loop: scan created tasks → select host → execute → update
- CliAdapterConfig: CLI templates for Codex and Claude Code
- Structured prompt construction (Issue → goal/constraints/validation)
- Output parsers: Codex JSON, Claude Code JSON, raw fallback
- TaskStatus::ReviewPending + review_count loop limit
- Forgejo webhook: pull_request (opened→review_pending, merged→completed)
- Forgejo webhook: push events (task/* branch → last_activity_at)
- HTTP API: dequeue only returns http_pull tasks
- HTTP API: status update only for http_pull mode
- Token auth config for http_pull agents
- Adapter module rewritten: AgentAdapter trait removed → config-driven CLI templates
- New fields: execution_mode, assigned_host, branch_name, pr_title, last_activity_at, review_count
- 30/30 tests pass
2026-05-12 14:07:56 +08:00

2.7 KiB
Raw Blame History

Why

当前 adapter-cross-machine-revision change 设计了纯 Pull 模型Agent 主动调 HTTP API 拉取任务),但这不是 subprocess CLI 的真正跨机等价:

  • subprocess CLIOrchestrator 主动拉起 Agent构造上下文控制生命周期。Agent 跑完退出。
  • HTTP PullAgent 必须自己已经在运行,自己来拉任务,自己管生命周期。控制权反转。

Pull 模型无法解决:

  1. 上下文传递Agent 拉到 task JSON 后要自己构建 prompt、加载仓库、决定怎么执行
  2. Agent 不在运行Orchestrator 无法启动远程机器上的 Agent
  3. 生命周期管理Orchestrator 无法控制 Agent 启停

SSH + CLI 才是 subprocess 的真正跨机等价:控制流、上下文传递、生命周期管理与本地 spawn 完全一致。

同时HTTP Pull 模式对外部 AgentOpenClaw/Jeeves、Hermes 等)仍有价值——这些 Agent 有自己的调度和运行时,只需要通过 API 查询/更新状态。

因此需要设计双执行模型

What Changes

  • 新增 SSH + CLI 执行模式Orchestrator 通过 SSH 在远程机器上 spawn Agent CLI传入结构化 prompt收集输出
  • 保留 HTTP API:供外部 AgentOpenClaw/Jeeves、Hermes 等)自主接入
  • Task 模型新增 execution_mode 字段:ssh_cli | http_pull
  • Orchestrator 根据执行模式选择调度策略:
    • ssh_cliOrchestrator 主动 spawn → 等待完成 → 解析输出 → 生成 receipt
    • http_pullAgent 自主 dequeue → 自行执行 → 提交 receipt
  • 新增 SSH host 配置:每台远程机器的 SSH 连接信息
  • 新增 CLI 命令模板:每种 Agent 类型的 CLI 调用模板claude、codex、opencode

Capabilities

New Capabilities

  • ssh-cli-execution: Orchestrator 通过 SSH + CLI 在远程机器上执行 Agent是 subprocess 的跨机等价
  • host-management: 远程主机管理SSH 连接、Agent CLI 可用性检查)

Modified Capabilities

  • task-assignment-protocol: 补充双执行模式——ssh_cliOrchestrator 主动调度)和 http_pullAgent 自主拉取)
  • agent-adapter: Adapter 定义为 CLI 命令模板 + 输出解析器,不再是 trait 或 protocol 描述
  • notification-via-forgejo: 通知机制在两种模式下都适用SSH CLI 模式的 Agent 也会创建 PR

Impact

  • 代码:新增 src/execution/ 模块SSH executor + CLI template + output parser
  • 配置:新增 [hosts] section远程机器 SSH 信息)和 agent CLI 模板
  • Task 模型:新增 execution_mode 字段
  • 依赖:新增 ssh2tokio-process + SSH 相关 crate