Skip to content

Commit 0647bf4

Browse files
committed
fix: preserve pending subagent completion announces
Signed-off-by: sallyom <[email protected]>
1 parent 4764258 commit 0647bf4

2 files changed

Lines changed: 38 additions & 12 deletions

File tree

src/agents/subagent-announce-delivery.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4526,6 +4526,44 @@ describe("deliverSubagentAnnouncement completion delivery", () => {
45264526
expect(sendMessage).not.toHaveBeenCalled();
45274527
});
45284528

4529+
it("preserves pending completion announce delivery without media fallback", async () => {
4530+
const callGateway = createGatewayMock({
4531+
runId: "subagent:child:ok",
4532+
status: "accepted",
4533+
acceptedAt: Date.now(),
4534+
});
4535+
const sendMessage = createSendMessageMock();
4536+
const result = await deliverSlackChannelAnnouncement({
4537+
callGateway,
4538+
sendMessage,
4539+
sessionId: "requester-session-channel",
4540+
isActive: false,
4541+
expectsCompletionMessage: true,
4542+
directIdempotencyKey: "announce-channel-completion-pending",
4543+
internalEvents: [
4544+
{
4545+
type: "task_completion",
4546+
source: "subagent",
4547+
childSessionKey: "agent:worker:subagent:child",
4548+
childSessionId: "child-session-id",
4549+
announceType: "subagent task",
4550+
taskLabel: "channel completion smoke",
4551+
status: "ok",
4552+
statusLabel: "completed successfully",
4553+
result: "child completion output",
4554+
replyInstruction: "Summarize the result.",
4555+
},
4556+
],
4557+
});
4558+
4559+
expectRecordFields(result, {
4560+
delivered: true,
4561+
path: "direct",
4562+
});
4563+
expect(callGateway).toHaveBeenCalledTimes(1);
4564+
expect(sendMessage).not.toHaveBeenCalled();
4565+
});
4566+
45294567
it("does not fail stale channel subagent completions only because the parent stayed private", async () => {
45304568
const callGateway = createGatewayMock({
45314569
result: {

src/agents/subagent-announce-delivery.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,18 +1495,6 @@ async function sendSubagentAnnounceDirectly(params: {
14951495

14961496
const directAnnounceStillPending = isGatewayAgentRunPending(directAnnounceResponse);
14971497
if (directAnnounceStillPending) {
1498-
if (
1499-
params.expectsCompletionMessage &&
1500-
expectedMediaUrls.length === 0 &&
1501-
!requiresMessageToolDelivery
1502-
) {
1503-
return {
1504-
delivered: false,
1505-
path: "direct",
1506-
reason: "completion_handoff_pending",
1507-
error: "completion agent handoff is still pending",
1508-
};
1509-
}
15101498
return {
15111499
delivered: true,
15121500
path: "direct",

0 commit comments

Comments
 (0)