Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(session): release stopped continuation before awaiting abort
zqchrisf1e09fa5d86e
diff --git a/docs/dev-rules/pi-harness.md b/docs/dev-rules/pi-harness.mdindex 1b91c5e146..c676424647 100644--- a/docs/dev-rules/pi-harness.md+++ b/docs/dev-rules/pi-harness.md@@ -240,6 +240,8 @@ Pi CLI 管理入口、内核自更新与旧工具兼容的执行边界见Host 已放弃续跑时,即使 turn lease 记账失败,也应按原实例与 generation 释放退役等待;记账失败仍不得据此派发后续工作或重放副作用。只有 Host 实际登记续跑的 generation才能阻止空闲关闭;远端/无 observer 接管的 silent-stop 不得凭终态自行占有续跑门。+ 用户 Stop 发出 abort 后、等待 RPC 回执前即按 generation 撤销 Host 续跑门;+ 挂起的 abort 不得阻止已结算工作的待退役 runtime 关闭,迟到返回不得复活旧实例。延迟退役的实际关闭若失败,应在该实例的监听器清理前补发 `partial` 与`restart-cindy-to-refresh-packages` 恢复回执;不改判此前成功结果,不自动重放工作。- 设置页明确要求停用/移除的即时失效路径仍可关闭运行时;Session 必须在清除监听器和diff --git a/packages/maker-core/src/session.close.test.ts b/packages/maker-core/src/session.close.test.tsindex 8ee5afc8f4..6df6903129 100644--- a/packages/maker-core/src/session.close.test.ts+++ b/packages/maker-core/src/session.close.test.ts@@ -183,6 +183,33 @@ describe('Session close lifecycle', () => {await expect(session.send('late continuation')).rejects.toThrow(/closed|closing/);});+ it('retires a stopped silent-stop caller without waiting for its hung abort RPC', async () => {+ const { session, handle, queue, seen, idle } = liveTurn();+ const abortGate = createDeferred();+ vi.mocked(handle.abort).mockImplementation(() => abortGate.promise);+ await session.send('work');+ await session.closeAfterCurrentTurn();+ idle();+ queue.push({ type: 'done', source: 'pi', data: { status: 'completed', silentStop: true } });+ await vi.waitFor(() => expect(seen).toHaveLength(1));+ const stopping = session.abort();+ try {+ await vi.waitFor(() => expect(session.getStatus()).toBe('closed'));+ expect(handle.abort).toHaveBeenCalledOnce();+ expect(handle.close).toHaveBeenCalledOnce();+ expect(handle.send).toHaveBeenCalledOnce();+ await expect(session.send('late continuation')).rejects.toThrow(/closed|closing/);+ abortGate.resolve();+ await stopping;+ expect(session.getStatus()).toBe('closed');+ expect(handle.close).toHaveBeenCalledOnce();+ } finally {+ abortGate.resolve();+ await stopping;+ await session.close();+ }+ });+it('ignores a stale Host continuation settlement after a newer turn starts', async () => {const { session, handle, queue, seen, idle } = liveTurn();await session.send('work');diff --git a/packages/maker-core/src/session.ts b/packages/maker-core/src/session.tsindex 7ac36d1e1f..e7caec0a67 100644--- a/packages/maker-core/src/session.ts+++ b/packages/maker-core/src/session.ts@@ -1100,7 +1100,11 @@ export class Session {this.scheduleAbortRecoveryCheck(MANUAL_ABORT_RECOVERY_GRACE_MS, 'manual-abort');this.setStatus('aborting');try {- await this.handle.abort();+ const aborting = this.handle.abort();+ // Stop revokes Host continuation immediately. The RPC may never settle;+ // do not let its acknowledgement own an already-settled turn's retirement.+ this.settleHostTurnContinuation(abortGeneration);+ await aborting;} finally {this.releaseSendReservationIfObserved();if (this.status === 'aborting') {