feat: agent adapter CLI protocol — sessionId in result, continue support, format options #384

Closed
opened 2026-05-22 09:03:35 +00:00 by xiaoju · 0 comments
Owner

背景

Dogfood 发现两个问题:

  1. Session 追踪不可靠 — hermes agent 从 stderr 解析 session_id,偶发失败导致 detail 退化为 raw text
  2. Engine 无法对 agent 进行多轮校验(frontmatter 不合格时无法追加消息让 agent 修正)

设计

1. AgentRunResult 必须返回 sessionId

type AgentRunResult = {
  output: string
  detailHash: string
  sessionId: string  // 必填
}

所有 agent adapter 必须返回 sessionId,用于 session 追踪和后续 continue。

2. Agent 接口支持 continue

type AgentOptions = {
  name: string
  run(ctx: AgentContext): Promise<AgentRunResult>
  continue(sessionId: string, message: string): Promise<AgentRunResult>
}

continue 用于 engine 层校验失败时追加消息让 agent 继续(如 frontmatter 缺失字段)。

3. Hermes 实现

  • run()hermes chat -q ... --quiet → 解析 sessionId
  • continue()hermes chat --resume <sessionId> -q <message> --quiet

4. 输出格式

Agent CLI 输出支持 json/yaml 两种格式(跟 uwf 主 CLI 一致),包含 sessionId:

{"stepHash": "...", "sessionId": "..."}

待定

  • Engine 层校验循环的 maxRetries(建议 2)
  • continue 失败时的降级策略(直接 fail step)
## 背景 Dogfood 发现两个问题: 1. Session 追踪不可靠 — hermes agent 从 stderr 解析 session_id,偶发失败导致 detail 退化为 raw text 2. Engine 无法对 agent 进行多轮校验(frontmatter 不合格时无法追加消息让 agent 修正) ## 设计 ### 1. AgentRunResult 必须返回 sessionId ```typescript type AgentRunResult = { output: string detailHash: string sessionId: string // 必填 } ``` 所有 agent adapter 必须返回 sessionId,用于 session 追踪和后续 continue。 ### 2. Agent 接口支持 continue ```typescript type AgentOptions = { name: string run(ctx: AgentContext): Promise<AgentRunResult> continue(sessionId: string, message: string): Promise<AgentRunResult> } ``` `continue` 用于 engine 层校验失败时追加消息让 agent 继续(如 frontmatter 缺失字段)。 ### 3. Hermes 实现 - `run()` → `hermes chat -q ... --quiet` → 解析 sessionId - `continue()` → `hermes chat --resume <sessionId> -q <message> --quiet` ### 4. 输出格式 Agent CLI 输出支持 json/yaml 两种格式(跟 uwf 主 CLI 一致),包含 sessionId: ```json {"stepHash": "...", "sessionId": "..."} ``` ## 待定 - Engine 层校验循环的 maxRetries(建议 2) - continue 失败时的降级策略(直接 fail step)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#384