fix(subagents): include tool role in subagent completion output

This commit is contained in:
Peter Steinberger
2026-02-18 02:57:25 +01:00
parent 985ec71c55
commit 0dd97feb41
3 changed files with 40 additions and 5 deletions

View File

@@ -232,6 +232,36 @@ describe("subagent announce formatting", () => {
expect(msg).toContain("tool output line 1");
});
it("falls back to latest tool output when assistant reply is empty", async () => {
const { runSubagentAnnounceFlow } = await import("./subagent-announce.js");
chatHistoryMock.mockResolvedValueOnce({
messages: [
{
role: "assistant",
content: [{ type: "text", text: "" }],
},
{
role: "tool",
content: [{ type: "text", text: "tool output line 2" }],
},
],
});
readLatestAssistantReplyMock.mockResolvedValue("");
await runSubagentAnnounceFlow({
childSessionKey: "agent:main:subagent:worker",
childRunId: "run-tool-fallback-2",
requesterSessionKey: "agent:main:main",
requesterDisplayKey: "main",
...defaultOutcomeAnnounce,
waitForCompletion: false,
});
const call = agentSpy.mock.calls[0]?.[0] as { params?: { message?: string } };
const msg = call?.params?.message as string;
expect(msg).toContain("tool output line 2");
});
it("keeps full findings and includes compact stats", async () => {
const { runSubagentAnnounceFlow } = await import("./subagent-announce.js");
sessionStore = {