fix(agent-loop): harden lifecycle edge cases

This commit is contained in:
Tianyi Cui
2026-06-17 21:25:47 +08:00
parent f860474f8b
commit 6fdd048123
5 files changed
+167 -21

No files matched your search

+6 -5
View File
@@ -82,11 +82,12 @@ export interface Agent {
/**
* Resolve once the agent has reached quiescence after settling out of
* `running`, or immediately if it is already idle. The quiescence signal a
* teardown awaits: `agent.abort()` then `await agent.whenIdle()` guarantees
* the in-flight turn has fully stopped before the caller proceeds (a closing
* ACP connection, a disposing UI plugin), rather than returning while the
* driver is still streaming.
* `running`, or immediately if it is already idle with no queued work. The
* quiescence signal a teardown awaits: `agent.abort()` then
* `await agent.whenIdle()` guarantees queued/running work has fully stopped
* before the caller proceeds (a closing ACP connection, a disposing UI
* plugin), rather than returning while the driver is still streaming or about
* to start a queued turn.
*
* "Quiescence", not merely "status changed": a disposed agent emits
* `agent/status('disposed')` from inside its disposer, BEFORE the driver loop