Skip to content

control: 研究 Pi-native 的全局安全暂停,让所有 Agent 在下一执行边界停住 #161

Open

Description

@tt-a1i

一句话结论

OMP 的 /pause 不是 cancel-all:它允许已开始的 provider stream / tool call 正常完成,然后在下一次 model call 或 tool call 前停住主 Agent、in-process subagent 和 advisor;resume 后原队列继续。

这是很有价值的 operator control primitive。OpenPI 可以研究对应能力,但正确位置应优先是 Pi agent loop seam;不能靠各 extension 分别打一个 pause flag 来伪装原子全局暂停。

固定证据

对比固定在:

  • OpenPI main@2a69d3f32994da4123f1312b7fa84ef3d6119be1
  • OMP main@151dc754e8cd9314721aa6c78a168a205a4b0e4c

OMP 当前:

  • /pause 只在 interactive TUI 可用,process-global gate 覆盖 main、in-process subagents、advisor;in-flight work 不 abort,新工作不开始:command contract
  • agent loop 在每次 provider turn 前检查 gate:model boundary
  • 每个 tool call 真正开始前再次检查 gate;已经执行的 tool 不受影响:tool boundary
  • 单个 run 的 AbortSignal 可让它从 pause wait 中退出,但不会释放全局 gate:pause gate semantics, wait behavior

OpenPI 当前:

  • control surface 分散为 subagent_cancel、workflow_stop、bg_kill,分别属于不同 owner:owned control tools
  • 这些是终止单个/一组 owner work 的命令,不是“让 Pi main + 所有 child 在安全边界暂时静止”。
  • OpenPI extension 无法仅凭自身证明在 Pi provider/tool dispatch 前建立全局 gate。

为什么值得讨论

暂停与取消解决不同问题:

  • 用户发现环境、凭证、branch 或需求需要先确认,但不想杀掉长时间调查;
  • 多个 child 正在运行,需要先阻止它们继续发起新模型/工具动作,再逐个检查;
  • provider 429、成本异常或外部系统故障时,希望立即阻止新的请求,同时让已开始的写操作完整结算;
  • operator 想获得一个稳定观察窗口,而不是和持续变化的 dashboard 竞速。

这属于 operator authority 和 runtime lifecycle,不是模型判断。

OpenPI 应保留的优势

  • Pi 是所有 in-process Session 的 owner;暂停原语应位于 Pi loop,而不是 OpenPI 第二控制面;
  • pause 不改变 Task/Goal/Workflow canonical status;
  • 不把 pause 当 success、cancel 或 quiesced receipt;
  • 不自动恢复;恢复必须来自明确 operator action 或调用方协议;
  • Background Terminal 是外部 process,是否继续运行必须单独定义,不能假装 Pi Agent gate 已暂停它。

需要先设计的边界

  • scope:当前 Session tree、当前 Pi process,还是所有 OpenPI-owned external process?
  • safe boundary:provider request 前、tool execute 前、child spawn admission 前、completion-triggered wake 前;
  • 已开始的 mutating tool、Workflow sandbox、Background Terminal 是否完成、冻结或只禁止后续步骤;
  • paused 时新 user input 是排队、允许 control command,还是隐式 resume?
  • cancel/interrupt while paused 如何只终止目标,不释放其他 Agent;
  • RPC/ACP/print 模式如何表示 paused,不制造永远 busy 的客户端状态;
  • shutdown 时是否自动释放 waiters,且不能因此启动新工作;
  • operator 如何看到“已请求 pause”与“所有 scope 已实际 parked”的区别。

非目标

  • 不用 pause 代替 cancel/kill;
  • 不暂停 OS 进程或线程;
  • 不在任意 tool 中间强行冻结;
  • 不由模型自动触发;
  • 不让 extension monkey-patch Pi internals;
  • 不声称按下 pause 时所有 Agent 已瞬间静止。

完成条件

  • 先确认或提出最小 Pi agent-loop pause seam
  • 定义 requested / partially parked / fully parked / resuming / running 状态和收据
  • main、Direct Subagent、Workflow child、completion-triggered turn 在下一安全边界一致停住
  • in-flight provider/tool 不被截断,cancel signal 仍可独立退出
  • 新 spawn/admission 与新的 provider request 在 paused 时不能穿透
  • Background Terminal 的独立语义明确且 UI 不误报
  • session switch、shutdown、RPC/ACP disconnect 的恢复/清理有测试
  • 没有 Pi seam 时记录 upstream requirement,不在 OpenPI 旁路实现假全局 gate

与现有 Issue 的关系

Activity

  1. added
    enhancement
    on Aug 25, 2026
  2. 627150795 commented on Aug 28, 2026

    @627150795
    Contributor

    I am taking a focused first pass on this issue: document the Pi-native pause boundary and state/receipt semantics, including the distinction from cancel, without adding an extension-level fake global pause. I will leave the upstream seam and implementation scope explicit.

  3. 627150795 commented on Aug 28, 2026

    @627150795
    Contributor

    Update: the focused Pi-native safe-pause contract is available in PR #257: https://github.com/tt-a1i/openpi/pull/257\n\nIt defines pause states/receipts, safe provider/tool/spawn boundaries, the distinction from cancel, and independent Background Terminal semantics. Validation passed: git diff --check, bun run lint, bun run typecheck. This PR is docs-only and records the required upstream Pi seam before any runtime implementation.

  4. tt-a1i commented on Sep 9, 2026

    @tt-a1i
    CollaboratorAuthor

    2026-09-09 source pass (not installed, not run). Canonical write-up: docs/research/EXPERIMENT_GLOBAL_PAUSE_2026-09-09.md on checkout a9b40f0.

    Still true: OpenPI can cancel/kill per owner (subagent_cancel, workflow_stop, bg_kill) plus session_shutdown. That is not a Pi-loop pause. Official Pi @earendil-works/pi-coding-agent 0.85.1 (6160683) still has abort/Escape/ctx.abort() and no /pause seam. PR #257 remains the closed source record for #277; the contract file is not in this tree.

    New community contrast (clones / npm pack under /tmp, no pi install):

    • OMP @oh-my-pi/pi-coding-agent 18.1.15 (856d937; issue-pinned 151dc754 pause.ts header unchanged) still parks at the next model and tool boundary because it owns agentLoop. Learn-from only; do not vendor.
    • pi-muselinn-harness 0.9.22 is the only vanilla-Pi /pause package found. It copies the OMP overlay and a process-global gate, but the main agent only awaits that gate inside tool_call. The next provider request still goes out. That is the extension-level fake gate this issue already forbids.
    • pi-stop 1.3.0 (no public repo field) is the opposite product: ctx.abort() then pgrep SIGINT→SIGTERM→SIGKILL against every pi-coding-agent on the machine. Ignore.

    No new Issue. /goal pause, workflow quota-pause, and session killAll stay out of this ticket. Background terminals remain an independent external process (see also the 2026-09-09 PTY//ps note).

  5. tt-a1i commented on Sep 9, 2026

    @tt-a1i
    CollaboratorAuthor

    2026-09-09 PR archaeology (not installed, not run). Follow-up to the same-day cancel-vs-pause note: docs/research/EXPERIMENT_PAUSE_PR257_2026-09-09.md on checkout a9b40f0.

    What #257 actually specified (unmerged; commit 851e248, blob a03301a0, 140 lines): running → pause-requested → partially-parked → fully-parked → resuming → running. Receipts need scope, generation, requested/observed time, and per-owner status. Timeout/disconnect is uncertain, never fully-parked. Gate checks sit before the next provider request, tool execute, child/Workflow admission, and completion-triggered turn. In-flight streams/mutating tools finish; cancel stays independent. Background Terminal is out of the gate. The file says it does not implement pause.

    Why it closed: #277 Execution lifecycle source record (same boilerplate as #244/#246/#247/#250/#254/#255/#260). Maintainer said the content was not found wrong; do not rebase. GitHub merge_commit_sha 4fffc7bc is a test-merge into base fc4ab47, not a merge to main. origin/main 0d17f457 still 404s the contract. No successor consolidation record was drafted; #277 checkboxes remain empty.

    Still missing an official agent-loop seam. Pi 0.85.1 (d981de12 / clone 6160683) has abort/Escape/ctx.abort()/RPC { type: "abort" } only. tool_call / before_provider_request cannot park the next provider turn or emit a generation receipt. Do not implement an OpenPI /pause or rebase #257.

    State-name drift: this issue's checkbox says requested; the contract says pause-requested. No new Issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions