paperclipai/paperclip · error · Error

Agent selection failed

Error message

Agent selection failed

What it means

After the agent select prompt resolved, no agent in the list matched the selected id, so the wizard cannot continue with a concrete agent; a consistency guard on the selection result.

Solutions

  1. Retry; if it persists, verify the company has agents and the server is reachable.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at cli/src/commands/client/connect.ts:230 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18). Data as JSON: /api/errors/5b309d81cdeec5f0. Report an issue: GitHub.

Appendix: source

Thrown at cli/src/commands/client/connect.ts:230

  if (!selected) return null;
  return companies.find((company) => company.id === selected) ?? null;
}

async function chooseAgent(agents: Agent[], preferredAgentId: string | undefined): Promise<Agent> {
  const selected = await p.select({
    message: "Agent",
    initialValue: preferredAgentId && agents.some((agent) => agent.id === preferredAgentId)
      ? preferredAgentId
      : agents[0]?.id,
    options: agents.map((agent) => ({
      value: agent.id,
      label: agent.name,
      hint: agent.role,
    })),
  });
  assertNotCancelled(selected);
  const agent = agents.find((item) => item.id === selected);
  if (!agent) throw new Error("Agent selection failed");
  return agent;
}

function buildExports(input: {
  apiBase: string;
  companyId?: string;
  agentId?: string;
  envName: string;
  token: string;
}): string {
  const escaped = (value: string) => value.replace(/'/g, "'\"'\"'");
  return [
    `export PAPERCLIP_API_URL='${escaped(input.apiBase)}'`,
    input.companyId ? `export PAPERCLIP_COMPANY_ID='${escaped(input.companyId)}'` : null,
    input.agentId ? `export PAPERCLIP_AGENT_ID='${escaped(input.agentId)}'` : null,
    `export ${input.envName}='${escaped(input.token)}'`,
  ].filter((line): line is string => Boolean(line)).join("\n");
}

View on GitHub (pinned to 120ae5428f)