Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/junior/src/chat/task-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(" ");
}

Expand Down
11 changes: 11 additions & 0 deletions packages/junior/tests/unit/chat/task-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ",
Expand Down
Loading