feat(agent): agent.await suspends the session instead of holding a worker slot
When children are still running, agent.await records the wait, closes the session (the tool call stays pending in the JSONL) and drive returns suspended. runAgent waits with waitForFact for the children to settle, the deadline, or cancellation, then reopens the session; agent.await is replay-safe, so resume replays it and the model gets the real result. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
3e37ac8ae7
commit
d64f735810
4 files changed
+129
-24
No files matched your search
@@ -183,6 +183,12 @@ describe.skipIf(!hasPg)("E11 Pi 子代理(agent.spawn / agent.await)", () => {
|
||||
)!;
|
||||
const lastCompleted = events.filter((x) => x.type === "subagent_completed").at(-1)!;
|
||||
expect(Number(lastCompleted.seq)).toBeLessThan(Number(awaitEnd.seq));
|
||||
// agent.await 挂起(不占 worker):会话关闭 → waitForFact 等子会话 → 重开会话重放 agent.await
|
||||
expect((awaitEnd.payload as Any).recovery).toBe(true);
|
||||
expect(events.filter((x) => x.type === "run_started").map((x) => (x.payload as Any).resumed)).toEqual([
|
||||
false,
|
||||
true,
|
||||
]);
|
||||
// SSE:父会话 runId 上能看到子会话提示
|
||||
expect(seen.some((x) => x.payload.runId === parentId && x.payload.capabilityId === "agent.spawn")).toBe(true);
|
||||
|
||||
|
||||
Reference in new issue
Block a user