Skip to content

Commit 8055133

Browse files
HomicideZeroClaira
andauthored
fix: look up assignee agent name when executionAgentNameKey is null (#36)
When an agent completes an issue, the Discord notification shows "Completed by: Agent" instead of the agent's display name. Root cause: issue.executionAgentNameKey is not reliably populated by the Paperclip platform. When it's null, the fallback payload.agentName ?? "Agent" produces the literal string "Agent", which the formatter uses verbatim. Fix: if agentName is still null after the executionAgentNameKey assignment, look up the assignee agent by ID via ctx.agents.list() and use its name field (the display name — e.g. "Scribe", "Claira"). This resolves without any API changes on the platform side. Co-authored-by: Claira <claira@homicidezero.com>
1 parent 79d3a75 commit 8055133

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/worker.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ async function enrichIssueNotificationPayload(
171171
if (payload.assigneeAgentId == null) payload.assigneeAgentId = issue.assigneeAgentId;
172172
if (payload.assigneeUserId == null) payload.assigneeUserId = issue.assigneeUserId;
173173
if (payload.agentName == null) payload.agentName = issue.executionAgentNameKey;
174+
// executionAgentNameKey is not always populated — fall back to looking up the
175+
// assignee agent's display name so "Completed by" shows "Scribe" not "Agent".
176+
if (payload.agentName == null && (payload.assigneeAgentId || issue.assigneeAgentId)) {
177+
const agentId = payload.assigneeAgentId ?? issue.assigneeAgentId;
178+
const agents = await ctx.agents.list({ companyId });
179+
const match = (agents as Array<{ id: string; name: string }>).find((a) => a.id === agentId);
180+
if (match?.name) payload.agentName = match.name;
181+
}
174182
if (payload.completedAt == null && issue.completedAt) payload.completedAt = String(issue.completedAt);
175183
if (payload.updatedAt == null && issue.updatedAt) payload.updatedAt = String(issue.updatedAt);
176184
if (payload.projectName == null && issue.project?.name) payload.projectName = issue.project.name;

0 commit comments

Comments
 (0)