block/buzz · error · Error

This agent is present on the relay. Starting another instanc

Error message

This agent is present on the relay. Starting another instance is unavailable.

What it means

assertStartNotBlockedByPresence throws when a managed agent's relay presence (online/away) shows the agent is already running somewhere, so the desktop refuses to start a second instance. Availability comes from the presence query snapshot via getAvailability(agent.pubkey), and the block only fires when the local lifecycle is not itself active. The wording is deliberate: positive presence blocks another start but never grants lifecycle control.

Source

Thrown at desktop/src/features/agents/ui/useManagedAgentActions.ts:115

  const managedPubkeys = React.useMemo(
    () => new Set(managedAgents.map((agent) => agent.pubkey)),
    [managedAgents],
  );

  const managedPubkeyList = React.useMemo(
    () => managedAgents.map((agent) => agent.pubkey),
    [managedAgents],
  );

  const { query: managedPresenceQuery, getAvailability } =
    useAgentAvailabilityLookup(managedPubkeyList);

  function assertStartNotBlockedByPresence(agent: ManagedAgent) {
    const reason = agentPresenceStartBlockReason(
      isManagedAgentActive(agent),
      getAvailability(agent.pubkey),
    );
    if (reason) throw new Error(reason);
  }

  const channelsByPubkey = React.useMemo(() => {
    const map: Record<string, { id: string; name: string }[]> = {};
    // Seed from relay agent profiles (kind:10100 events).
    for (const ra of relayAgentsQuery.data ?? []) {
      if (ra.channels.length > 0) {
        // Skip entries missing a channel id rather than falling back to the
        // name as id — a misaligned channels/channelIds pairing would otherwise
        // produce a pill that silently navigates to a channel name as if it
        // were an id.
        map[normalizePubkey(ra.pubkey)] = ra.channels.flatMap((name, i) => {
          const id = ra.channelIds[i];
          return id ? [{ id, name }] : [];
        });
      }
    }
    // Fill in from channel member lists (kind:39002) for any managed agents

View on GitHub (pinned to dad5a33865)

Solutions

  1. Stop the existing agent instance first (from the device that owns it) and wait for presence to flip to offline, then retry Start.
  2. Verify the relay presence snapshot is current — confirm the app is connected and the presence query has refreshed for this pubkey.
  3. If the other instance is dead but presence lingers, stop/kill the orphaned process and restart the relay session so presence clears.
  4. If the local record is wrong (agent not actually running anywhere), refresh the agent inventory and retry after presence updates.

Example fix

// before
toast.success('Started agent');
await startManagedAgent(agent);

// after
const availability = getAvailability(agent.pubkey);
const reason = agentPresenceStartBlockReason(isManagedAgentActive(agent), availability);
if (reason) {
  toast.error(reason); // surface the block instead of attempting the start
  return;
}
await startManagedAgent(agent);
Defensive patterns

Strategy: validation

Validate before calling

import { agentPresenceStartBlockReason } from "@/features/agents/lib/useAgentAvailability";
const block = agentPresenceStartBlockReason(isManagedAgentActive(agent), getAvailability(agent.pubkey));
if (block) { /* disable Start / show reason */ }

Type guard

const canStart = (a: ManagedAgent): boolean =>
  agentPresenceStartBlockReason(isManagedAgentActive(a), getAvailability(a.pubkey)) === undefined;

Try / catch

try {
  await handleStart(agent);
} catch (e) {
  if (e instanceof Error && e.message.includes("present on the relay")) {
    toast.info("This agent is already running elsewhere. Stop it first.");
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling handleStart or handleRestart on a managed agent whose pubkey resolves to presence 'online' or 'away' in the current connected presence snapshot, while the local agent record is inactive. Also occurs when another device or session is running the same agent identity.

Common situations: User starts the agent from a second desktop device; a stale-but-live presence snapshot still shows the agent online after a crash elsewhere; an old agent process on another machine is still connected to the relay; user clicks Start on a relay-hosted agent that is already deployed.

Related errors


AI-assisted analysis of block/buzz@dad5a33865 (2026-09-05). Data as JSON: /api/errors/6e2690af51b0a6f2. Report an issue: GitHub.