Skip to content

Commit cc092fa

Browse files
committed
fix(subagent): drop in-flight tool ids on resume.tool_result
Parked-approval deny answers with resume.tool_result, not tool.done. Leaving the id outstanding would reset stall silence forever.
1 parent c6365fd commit cc092fa

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

src/subagent/nudge-director.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ function toolDone(callId: string, isError = false): ReactorInboundEvent {
123123
} as unknown as ReactorInboundEvent;
124124
}
125125

126+
function resumeToolResult(callId: string): ReactorInboundEvent {
127+
return {
128+
type: "resume.tool_result",
129+
result: { callId, content: "denied by approver", isError: true },
130+
} as unknown as ReactorInboundEvent;
131+
}
132+
126133
function messageReceived(content: string): ReactorInboundEvent {
127134
return {
128135
type: "message.received",
@@ -1214,6 +1221,33 @@ describe("SubAgentDirector stall nudge grace", () => {
12141221
});
12151222
});
12161223

1224+
test("resume.tool_result clears in-flight ids so later silence can stall-nudge", async () => {
1225+
let now = 5_000_000;
1226+
const director = new SubAgentDirector(
1227+
"system",
1228+
[],
1229+
undefined,
1230+
1_000,
1231+
() => now,
1232+
);
1233+
const caps = capabilities();
1234+
1235+
await director.decide(inferenceDone(["parked-1"]), state, caps);
1236+
now += 60_000;
1237+
expect(
1238+
actions(await director.decide(messageReceived(""), state, caps)),
1239+
).toEqual([{ type: "wait" }]);
1240+
1241+
await director.decide(resumeToolResult("parked-1"), state, caps);
1242+
now += 1_000;
1243+
expect(
1244+
actions(await director.decide(messageReceived(""), state, caps)),
1245+
).toContainEqual({
1246+
type: "checkpoint",
1247+
message: "subagent-stall-nudge",
1248+
});
1249+
});
1250+
12171251
test("two queued empty pings in the same tick nudge then wait, not stop", async () => {
12181252
let now = 3_000_000;
12191253
const director = new SubAgentDirector(

src/subagent/nudge-director.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ export class SubAgentDirector extends DefaultDirector {
462462
return terminal;
463463
}
464464
}
465-
if (event.type === "tool.done") {
465+
if (event.type === "tool.done" || event.type === "resume.tool_result") {
466466
this.lastActivityAt = this.now();
467467
this.stallNudgeAt = undefined;
468468
this.inFlightToolCallIds.delete(event.result.callId);

0 commit comments

Comments
 (0)