diff --git a/desktop/src/features/agents/lib/agentAutocompleteEligibility.ts b/desktop/src/features/agents/lib/agentAutocompleteEligibility.ts index e4afe7fea4..6763cbb7d5 100644 --- a/desktop/src/features/agents/lib/agentAutocompleteEligibility.ts +++ b/desktop/src/features/agents/lib/agentAutocompleteEligibility.ts @@ -57,10 +57,16 @@ export function getMentionableAgentPubkeys({ export function isAgentIdentityInManagedList( candidate: { isAgent?: boolean; pubkey: string }, managedAgentPubkeys: ReadonlySet, + mentionableAgentPubkeys?: ReadonlySet, ) { + const pubkey = normalizePubkey(candidate.pubkey); return ( candidate.isAgent !== true || - managedAgentPubkeys.has(normalizePubkey(candidate.pubkey)) + managedAgentPubkeys.has(pubkey) || + // Externally-hosted agents (relay directory, kind:10100) that are + // invocable for the current user are legitimate mention targets even + // though no local managed-agent record exists for them. + (mentionableAgentPubkeys?.has(pubkey) ?? false) ); } diff --git a/desktop/src/features/messages/lib/useMentions.ts b/desktop/src/features/messages/lib/useMentions.ts index 0c73b75339..bd944e141f 100644 --- a/desktop/src/features/messages/lib/useMentions.ts +++ b/desktop/src/features/messages/lib/useMentions.ts @@ -246,7 +246,13 @@ export function useMentions( if (isArchivedDiscovery(pubkey)) { return; } - if (!isAgentIdentityInManagedList(candidate, managedAgentPubkeys)) { + if ( + !isAgentIdentityInManagedList( + candidate, + managedAgentPubkeys, + mentionableAgentPubkeys, + ) + ) { return; } if (