From 0b72f1a72f036380866aa30489a2eb9b2a38354b Mon Sep 17 00:00:00 2001 From: Taylor Ho Date: Thu, 21 May 2026 23:06:58 -0700 Subject: [PATCH] fix: pass context to single-add mutation so reuse guard fires MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The single-agent create path was calling createChannelManagedAgent without context, so the reuse guard (findReusablePersonaAgent) never fired — always spawning a new keypair + process. Now fetches managedAgents + channelMemberPubkeys before calling create, matching the batch path's behavior. --- desktop/src/features/agents/hooks.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/desktop/src/features/agents/hooks.ts b/desktop/src/features/agents/hooks.ts index b3500b55df..0609d3ab95 100644 --- a/desktop/src/features/agents/hooks.ts +++ b/desktop/src/features/agents/hooks.ts @@ -13,6 +13,7 @@ import { discoverAcpProviders, discoverBackendProviders, discoverManagedAgentPrereqs, + getChannelMembers, getManagedAgentLog, listManagedAgents, listRelayAgents, @@ -417,7 +418,18 @@ export function useCreateChannelManagedAgentMutation(channelId: string | null) { throw new Error("No channel selected."); } - return createChannelManagedAgent(channelId, input); + const [managedAgents, members] = await Promise.all([ + listManagedAgents(), + getChannelMembers(channelId), + ]); + const channelMemberPubkeys = new Set( + members.map((m) => normalizePubkey(m.pubkey)), + ); + + return createChannelManagedAgent(channelId, input, { + managedAgents, + channelMemberPubkeys, + }); }, onSuccess: (result) => { if (!channelId) return;