fix(issues): skip non-invokable mention wake targets
This commit is contained in:
parent
eb9f954bae
commit
ff4992ffc3
|
|
@ -864,14 +864,20 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("resolves only structured same-company agent mentions", async () => {
|
||||
it("resolves only structured same-company wakeable agent mentions", async () => {
|
||||
const companyId = await seedAssignableAgentCompany();
|
||||
const otherCompanyId = await seedAssignableAgentCompany();
|
||||
const localAgentId = randomUUID();
|
||||
const foreignAgentId = randomUUID();
|
||||
const terminatedAgentId = randomUUID();
|
||||
const pausedAgentId = randomUUID();
|
||||
const pendingAgentId = randomUUID();
|
||||
|
||||
await db.insert(agents).values([
|
||||
agentRow(companyId, { id: localAgentId, name: "LocalAgent" }),
|
||||
agentRow(companyId, { id: terminatedAgentId, name: "TerminatedAgent", status: "terminated" }),
|
||||
agentRow(companyId, { id: pausedAgentId, name: "PausedAgent", status: "paused" }),
|
||||
agentRow(companyId, { id: pendingAgentId, name: "PendingAgent", status: "pending_approval" }),
|
||||
agentRow(otherCompanyId, { id: foreignAgentId, name: "ForeignAgent" }),
|
||||
]);
|
||||
|
||||
|
|
@ -879,6 +885,9 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {
|
|||
companyId,
|
||||
[
|
||||
`hello [@LocalAgent](${buildAgentMentionHref(localAgentId)})`,
|
||||
`skip [@TerminatedAgent](${buildAgentMentionHref(terminatedAgentId)})`,
|
||||
`skip [@PausedAgent](${buildAgentMentionHref(pausedAgentId)})`,
|
||||
`skip [@PendingAgent](${buildAgentMentionHref(pendingAgentId)})`,
|
||||
`and [@ForeignAgent](${buildAgentMentionHref(foreignAgentId)})`,
|
||||
].join(" "),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ import {
|
|||
issueCommentAuthorTypeSchema,
|
||||
issueCommentMetadataSchema,
|
||||
issueCommentPresentationSchema,
|
||||
isAgentInvokable,
|
||||
isUuidLike,
|
||||
normalizeIssueIdentifier as normalizeIssueReferenceIdentifier,
|
||||
} from "@paperclipai/shared";
|
||||
|
|
@ -12849,14 +12850,20 @@ export function issueService(db: Db) {
|
|||
const explicitAgentMentionIds = extractAgentMentionIds(body);
|
||||
if (explicitAgentMentionIds.length === 0) return [];
|
||||
|
||||
const rows = await db
|
||||
.select({ id: agents.id })
|
||||
.from(agents)
|
||||
.where(eq(agents.companyId, companyId));
|
||||
const companyAgentIds = new Set(rows.map((agent) => agent.id));
|
||||
return explicitAgentMentionIds.filter((agentId) =>
|
||||
companyAgentIds.has(agentId),
|
||||
const rows = await db.select({
|
||||
id: agents.id,
|
||||
companyId: agents.companyId,
|
||||
name: agents.name,
|
||||
status: agents.status,
|
||||
reportsTo: agents.reportsTo,
|
||||
})
|
||||
.from(agents).where(eq(agents.companyId, companyId));
|
||||
const wakeableCompanyAgentIds = new Set(
|
||||
rows
|
||||
.filter((agent) => isAgentInvokable({ agent, agents: rows }))
|
||||
.map((agent) => agent.id),
|
||||
);
|
||||
return explicitAgentMentionIds.filter((agentId) => wakeableCompanyAgentIds.has(agentId));
|
||||
},
|
||||
|
||||
findMentionedProjectIds: async (
|
||||
|
|
|
|||
Loading…
Reference in New Issue