feat(cli): thread step --background + thread running #456

Closed
opened 2026-05-24 04:19:16 +00:00 by xiaomo · 0 comments
Owner

背景

uwf thread step 是同步阻塞的,执行 moderator→agent→extract 循环期间占住终端。多步执行 (-c 10) 时尤其痛苦。同时,多终端并行跑 step 时没有办法看到当前有哪些 thread 在执行。

需求

1. uwf thread running — 查看正在执行的 sessions

优先做这个,独立有价值。

  • step 开始时写锁文件到 ~/.uncaged/workflow/running/(以 threadId 命名)
  • step 结束(成功/失败)时清除
  • uwf thread running 读取并输出 JSON:
[
  {
    "threadId": "abc123",
    "bundleHash": "XYZ789",
    "workflowName": "solve-issue",
    "pid": 54321,
    "startedAt": 1716520800000,
    "agent": "uwf-hermes",
    "currentStep": 3,
    "maxSteps": 10
  }
]
  • PID 失效(进程已死但锁文件残留)时自动清理

2. uwf thread step <id> --background — 后台执行

基于 running 状态管理,fork 子进程执行 step:

  • --background flag,fork 后立即返回,打印 threadId + PID
  • 日志照常写 JSONL
  • 进程结束后清除 running 锁文件
  • 搭配 uwf thread running 查看状态

实现建议

  • 输出格式统一 JSON(与 thread show 一致)
  • 锁文件建议用 JSON,包含上述字段
  • 不需要 daemon 模式,进程级后台足够

不做

  • daemon 托管模式(复杂度太高,当前不需要)
## 背景 `uwf thread step` 是同步阻塞的,执行 moderator→agent→extract 循环期间占住终端。多步执行 (`-c 10`) 时尤其痛苦。同时,多终端并行跑 step 时没有办法看到当前有哪些 thread 在执行。 ## 需求 ### 1. `uwf thread running` — 查看正在执行的 sessions **优先做这个,独立有价值。** - step 开始时写锁文件到 `~/.uncaged/workflow/running/`(以 threadId 命名) - step 结束(成功/失败)时清除 - `uwf thread running` 读取并输出 JSON: ```json [ { "threadId": "abc123", "bundleHash": "XYZ789", "workflowName": "solve-issue", "pid": 54321, "startedAt": 1716520800000, "agent": "uwf-hermes", "currentStep": 3, "maxSteps": 10 } ] ``` - PID 失效(进程已死但锁文件残留)时自动清理 ### 2. `uwf thread step <id> --background` — 后台执行 基于 running 状态管理,fork 子进程执行 step: - `--background` flag,fork 后立即返回,打印 threadId + PID - 日志照常写 JSONL - 进程结束后清除 running 锁文件 - 搭配 `uwf thread running` 查看状态 ## 实现建议 - 输出格式统一 JSON(与 `thread show` 一致) - 锁文件建议用 JSON,包含上述字段 - 不需要 daemon 模式,进程级后台足够 ## 不做 - daemon 托管模式(复杂度太高,当前不需要)
xiaoju was assigned by xiaomo 2026-05-24 04:19:16 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#456