Skip to content

Commit 29bca1b

Browse files
Reset the tool-less narration count on tool-using turns (#956)
1 parent 4979a1a commit 29bca1b

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/subagent/nudge-director.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,35 @@ describe("SubAgentDirector incomplete-report wiring", () => {
794794
expect(reply.content).toContain("read-1.ts");
795795
});
796796

797+
test("tool-using turns reset the tool-less narration count (CL-7788)", async () => {
798+
const director = new SubAgentDirector("system", [], undefined, 30);
799+
const caps = capabilities();
800+
801+
await director.decide(
802+
inferenceDoneText("Still looking at the files..."),
803+
state,
804+
caps,
805+
);
806+
await director.decide(inferenceDone(["read-1"]), state, caps);
807+
await director.decide(toolDone("read-1"), state, caps);
808+
await director.decide(inferenceDone(["read-2"]), state, caps);
809+
await director.decide(toolDone("read-2"), state, caps);
810+
811+
const result = actions(
812+
await director.decide(
813+
inferenceDoneText("Still narrating, no envelope."),
814+
state,
815+
caps,
816+
),
817+
);
818+
expect(result).toContainEqual({
819+
type: "checkpoint",
820+
message: "subagent-incomplete-report-nudge",
821+
});
822+
expect(result.some((action) => action.type === "reply")).toBe(false);
823+
expect(result.some((action) => action.type === "infer")).toBe(true);
824+
});
825+
797826
test("tool-less turn with the four headings completes normally", async () => {
798827
const director = new SubAgentDirector("system", [], undefined, 30);
799828
const caps = capabilities();

src/subagent/nudge-director.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ export class SubAgentDirector extends DefaultDirector {
330330
this.lastAssistantText = lastText(content);
331331
const hasToolCalls = content.some((block) => block.type === "tool_call");
332332
if (hasToolCalls) {
333+
this.toolLessNarrationCycles = 0;
333334
this.verbatimToolCallNudgeFired = false;
334335
this.thrashState = nextThrashState(this.thrashState, content);
335336
}

0 commit comments

Comments
 (0)