From 480a68ba50cea4aa1edabe8c089b214a81dc12bc Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 16:33:12 +0000 Subject: [PATCH] fix(events): Tell the agent to write "you" to an Event doer outside People involved A requester who reviewed their own pull request got a watch reply that mentioned them and then named their GitHub login as a second person. The review events have no People involved, so the doer line never said to write "you" or to drop the handle. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com> --- packages/junior/src/chat/task-input.ts | 13 +++++++------ packages/junior/tests/unit/chat/task-input.test.ts | 11 +++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/junior/src/chat/task-input.ts b/packages/junior/src/chat/task-input.ts index a2029f836c..7f62644bb7 100644 --- a/packages/junior/src/chat/task-input.ts +++ b/packages/junior/src/chat/task-input.ts @@ -51,21 +51,22 @@ export interface EventDoneBy { /** * Connect the mention to the provider handle in the Event text. Without this, * the agent can mention a person and then name them again by handle as if - * they were someone else. + * they were someone else. The "you" rule also applies when the doer is not in + * People involved, because instructions can still ask the agent to mention + * them, such as a requester who reviews their own pull request. */ function doneByLine(doneBy: EventDoneBy, people: readonly string[]): string { const mention = oneLine(doneBy.mention); const handle = doneBy.handle ? oneLine(doneBy.handle) : undefined; + const asYou = `as "you"${handle ? `, and do not also call them "${handle}"` : ""}.`; return [ `Done by: ${mention}. This person did what this Event describes.`, ...(handle ? [`The Event calls them "${handle}". That is the same person.`] : []), - ...(people.includes(mention) - ? [ - `They are also in People involved. Write to them as "you"${handle ? `, and do not also call them "${handle}"` : ""}.`, - ] - : []), + people.includes(mention) + ? `They are also in People involved. Write to them ${asYou}` + : `If you mention them, write to them ${asYou}`, ].join(" "); } diff --git a/packages/junior/tests/unit/chat/task-input.test.ts b/packages/junior/tests/unit/chat/task-input.test.ts index fd26bcf6ea..75de027941 100644 --- a/packages/junior/tests/unit/chat/task-input.test.ts +++ b/packages/junior/tests/unit/chat/task-input.test.ts @@ -58,6 +58,17 @@ describe("renderTaskInput", () => { `); }); + it("links the doer's handle to their mention without People involved", () => { + const text = renderTaskInput({ + doneBy: { mention: "<@U456>", handle: "octocat" }, + instructions: "Tell the person who asked when a review arrives.", + }); + + expect(text).toContain( + 'Done by: <@U456>. This person did what this Event describes. The Event calls them "octocat". That is the same person. If you mention them, write to them as "you", and do not also call them "octocat".\n', + ); + }); + it("omits empty optional sections and clips bounded fields", () => { const text = renderTaskInput({ about: " label ",