fix(subagents): strip leaked [[reply_to]] tags from completion announces (#34503)

* fix(subagents): strip reply tags from completion delivery text

* test(subagents): cover reply-tag stripping in cron completion sends

* changelog: note iMessage reply-tag stripping in completion announces

* Update CHANGELOG.md

* Apply suggestion from @greptile-apps[bot]

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
Vincent Koc
2026-03-05 07:50:55 -05:00
committed by GitHub
parent e5b6a4e19d
commit 4dc0c66399
3 changed files with 40 additions and 1 deletions

View File

@@ -430,6 +430,40 @@ describe("subagent announce formatting", () => {
expect(msg).not.toContain("Convert the result above into your normal assistant voice");
});
it("strips reply tags from cron completion direct-send messages", async () => {
sessionStore = {
"agent:main:subagent:test": {
sessionId: "child-session-cron-direct",
},
"agent:main:main": {
sessionId: "requester-session-cron-direct",
},
};
const didAnnounce = await runSubagentAnnounceFlow({
childSessionKey: "agent:main:subagent:test",
childRunId: "run-cron-reply-tag-strip",
requesterSessionKey: "agent:main:main",
requesterDisplayKey: "main",
requesterOrigin: { channel: "imessage", to: "imessage:+15550001111" },
...defaultOutcomeAnnounce,
announceType: "cron job",
expectsCompletionMessage: true,
roundOneReply:
"[[reply_to:6100]] this is a hype post + a gentle callout for the NYC meet. In short:",
});
expect(didAnnounce).toBe(true);
expect(sendSpy).toHaveBeenCalledTimes(1);
expect(agentSpy).not.toHaveBeenCalled();
const call = sendSpy.mock.calls[0]?.[0] as { params?: Record<string, unknown> };
const rawMessage = call?.params?.message;
const msg = typeof rawMessage === "string" ? rawMessage : "";
expect(call?.params?.channel).toBe("imessage");
expect(msg).toBe("this is a hype post + a gentle callout for the NYC meet. In short:");
expect(msg).not.toContain("[[reply_to:");
});
it("keeps direct completion send when only the announcing run itself is pending", async () => {
sessionStore = {
"agent:main:subagent:test": {