fix(coding-agent): drain follow-ups queued during agent_end

When an extension queues a follow-up during `agent_end` it
gets stuck on the follow-up queue until after the next user
message.

Add a hasQueuedMessages() check to _handlePostAgentRun
so the existing while/continue loop drains them.

- One-line fix in _handlePostAgentRun
- Integration test in agent-session-queue
- git-merge-and-resolve example extension with tests
This commit is contained in:
Danny Thomas
2026-05-28 18:15:50 +10:00
parent b85bf65678
commit a29a7902e9
5 changed files with 352 additions and 1 deletions

View File

@@ -419,4 +419,27 @@ describe("AgentSession queue characterization", () => {
'Extension command "/testcmd" cannot be queued. Use prompt() or execute the command when not streaming.',
);
});
it("delivers follow-ups queued during agent_end", async () => {
let sent = false;
const harness = await createHarness({
extensionFactories: [
(pi: ExtensionAPI) => {
pi.on("agent_end", async () => {
if (sent) return;
sent = true;
pi.sendUserMessage("conflict report", { deliverAs: "followUp" });
});
},
],
});
harnesses.push(harness);
harness.setResponses([fauxAssistantMessage("reply"), fauxAssistantMessage("follow-up reply")]);
await harness.session.prompt("hello");
await harness.session.agent.waitForIdle();
expect(getUserTexts(harness)).toEqual(["hello", "conflict report"]);
});
});