Fix task conversation auto routing

This commit is contained in:
klopez4212
2026-06-29 20:09:35 +01:00
parent 2050b1892a
commit 1ab33a430e
2 changed files with 16 additions and 3 deletions

View File

@@ -70,10 +70,20 @@ test("continued conversation auto-routes only a single messageable agent", () =>
["agent-one"],
);
assert.deepEqual(
getAutoRoutedAgentConversationPubkeys([
{ canMessage: true, pubkey: "agent-one" },
{ canMessage: false, pubkey: "agent-two" },
{ canMessage: false, pubkey: "agent-three" },
]),
["agent-one"],
);
assert.deepEqual(
getAutoRoutedAgentConversationPubkeys([
{ canMessage: true, pubkey: "agent-one" },
{ canMessage: true, pubkey: "agent-two" },
{ canMessage: false, pubkey: "agent-three" },
]),
[],
);

View File

@@ -110,12 +110,15 @@ export function agentConversationsStorageKey(
export function getAutoRoutedAgentConversationPubkeys(
participants: readonly AgentConversationRouteableParticipant[],
): string[] {
if (participants.length !== 1) {
const messageableParticipants = participants.filter(
(participant) => participant.canMessage,
);
if (messageableParticipants.length !== 1) {
return [];
}
const [participant] = participants;
return participant.canMessage ? [participant.pubkey] : [];
return [messageableParticipants[0].pubkey];
}
export function buildAgentConversationMentionPubkeys({