feat: thread/edge location — 为 workflow 添加运行位置概念 #558

Closed
opened 2026-05-27 14:11:03 +00:00 by xiaoju · 0 comments
Owner

背景

workflow 运行是一个任务,每个 step 是一个事件。事件有时间(timestamp,已有)和地点(cwd,缺失)。

当前 cwd 是隐式的 — agent 跑在哪取决于启动时的 shell 环境,workflow 定义和 thread 数据里都没有记录。导致:

  • 不可复现:同一个 thread 换个终端 resume,可能在不同目录
  • planner 要猜路径:靠 prompt 写死 repoPath
  • step detail 里找不到 agent 当时在哪跑的

设计

Thread 级 cwd

  • uwf thread start 时记录 cwd(必填,默认 process.cwd()
  • 所有 step 继承 thread.cwd
  • 存在 thread metadata 里

Edge 级 location

  • graph edge 新增 location 字段(可选)
  • 支持 mustache 模板:location: "{{{repoPath}}}"
  • moderator 解析后覆盖 thread.cwd,传给 agent adapter 作为 cwd
  • 不写则继承 thread.cwd

示例

graph:
  planner:
    ready:
      role: coder
      prompt: "Implement plan {{{plan}}}."
      location: "{{{repoPath}}}"

Step metadata

  • 每个 step 记录实际使用的 cwd

影响范围

  • workflow-protocol: StepNodePayload 加 cwd 字段
  • cli-workflow: thread start 记录 cwd,moderator 解析 location
  • agent adapter protocol: spawn agent 时传 cwd

小橘 🍊(NEKO Team)

## 背景 workflow 运行是一个任务,每个 step 是一个事件。事件有时间(timestamp,已有)和地点(cwd,缺失)。 当前 cwd 是隐式的 — agent 跑在哪取决于启动时的 shell 环境,workflow 定义和 thread 数据里都没有记录。导致: - 不可复现:同一个 thread 换个终端 resume,可能在不同目录 - planner 要猜路径:靠 prompt 写死 repoPath - step detail 里找不到 agent 当时在哪跑的 ## 设计 ### Thread 级 `cwd` - `uwf thread start` 时记录 `cwd`(必填,默认 `process.cwd()`) - 所有 step 继承 thread.cwd - 存在 thread metadata 里 ### Edge 级 `location` - graph edge 新增 `location` 字段(可选) - 支持 mustache 模板:`location: "{{{repoPath}}}"` - moderator 解析后覆盖 thread.cwd,传给 agent adapter 作为 cwd - 不写则继承 thread.cwd ### 示例 ```yaml graph: planner: ready: role: coder prompt: "Implement plan {{{plan}}}." location: "{{{repoPath}}}" ``` ### Step metadata - 每个 step 记录实际使用的 cwd ## 影响范围 - workflow-protocol: StepNodePayload 加 cwd 字段 - cli-workflow: thread start 记录 cwd,moderator 解析 location - agent adapter protocol: spawn agent 时传 cwd 小橘 🍊(NEKO Team)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#558