Limit DM task inference to one agent participant

This commit is contained in:
klopez4212
2026-06-30 13:56:40 +01:00
parent ab74fcfe49
commit db57069135
2 changed files with 27 additions and 8 deletions
@@ -104,6 +104,18 @@ test("DM task agent inference requires exactly one other known agent", () => {
[],
);
assert.deepEqual(
getDmTaskAgentPubkeys({
channel: channel({
channelType: "dm",
participantPubkeys: ["human", "agent-one", "human-two"],
}),
currentPubkey: "human",
knownAgentPubkeys,
}),
[],
);
assert.deepEqual(
getDmTaskAgentPubkeys({
channel: channel({
@@ -110,15 +110,22 @@ export function getDmTaskAgentPubkeys({
const normalizedCurrentPubkey = currentPubkey
? normalizePubkey(currentPubkey)
: null;
const otherParticipants = new Map<string, string>();
return singleKnownAgentPubkey(
channel.participantPubkeys.filter(
(pubkey) =>
!normalizedCurrentPubkey ||
normalizePubkey(pubkey) !== normalizedCurrentPubkey,
),
knownAgentPubkeys,
);
for (const pubkey of channel.participantPubkeys) {
const normalized = normalizePubkey(pubkey);
if (normalizedCurrentPubkey && normalized === normalizedCurrentPubkey) {
continue;
}
otherParticipants.set(normalized, pubkey);
}
if (otherParticipants.size !== 1) {
return [];
}
return singleKnownAgentPubkey(otherParticipants.values(), knownAgentPubkeys);
}
export function getThreadTaskAgentPubkeys({