feat(web): add turn-scoped cancellation - #385
Conversation
|
CI status note: Node 22/24 completed this PR's repository checks and failed only at the final fresh-install I reproduced the packed install independently: npm now admits Pi 0.85.0 through OpenPI's published No dependency workaround is mixed into this feature PR. |
tt-a1i
left a comment
There was a problem hiding this comment.
方向对,有一处应修;请用这份替换 #358
turn 范围(sessionId+commandId+epoch)、等 turn_settled(outcome=cancelled)、不乐观结算,这些都符合合同。#358 从 abort() 返回值推断取消,请关掉那份。
应修:cancelActiveTurn 里 Promise.race([settlement, abortFailure])。如果 abort() resolve 了,但又没有 assistant message_end,HTTP 会一直挂着(没有超时)。请给 settlement 加界,或把「abort 成功但未结算」变成明确的非终态/错误,而不是挂起。
CI 红是共享的打包 openpi web 冒烟,不是这份 diff 独有的。
tt-a1i
left a comment
There was a problem hiding this comment.
需要改:abort() 成功但没有 message_end 时 HTTP 会一直挂
上一评写成 COMMENT 偏软。cancelActiveTurn 里:
const abortFailure = new Promise<never>((_, reject) => {
void abortOperation.catch(reject);
});
const terminal = await Promise.race([settlement, abortFailure]);abort() resolve、又没有 assistant message_end 时,settlement 永不 settle,abortFailure 也不 reject,HTTP 无限等。这是取消合同上的无界挂起,合入前要加超时或明确的非终态/错误。
方向仍对:sessionId+commandId+epoch、等 turn_settled、替换 #358。CI 红仍是共享打包冒烟。
|
已按 review 修复并推送到 |
Adds a Stop control for the current Pi agent execution without stopping the Web Host. Requests bind to the Session, command, and execution epoch, so stale tabs cannot cancel a later execution.
Closes #342.
The runtime invokes native
AgentSession.abort()and waits foragent_settled. Individual assistant messages, includingtoolUse, do not establish execution completion. Cancellation needs an aborted assistant result; missing terminal evidence remains uncertain. The browser restores the control from snapshots and SSE and does not optimistically claim completion. Queued follow-ups remain under Pi ownership and may continue within the same execution; this does not introduce per-input cancellation or a second queue.Validation:
bun run checkpassed; final integrated focused Web tests passed 75/75. The repair's standalone Node 22 full suite passed 1405 tests with one skip, plus Vitest 30/30. CI is running against the updated head. Earlier live-provider evidence in the issue predates this repair and is not a new runtime acceptance result.