{"record":{"id":"33a09277b2ca76a6","repo":"paperclipai/paperclip","slug":"probe-found-no-matching-anthropic-agent","errorCode":null,"errorMessage":"Probe found no matching Anthropic Agent","messagePattern":"Probe found no matching Anthropic Agent","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/managed-agent.ts","lineNumber":294,"sourceCode":"      \"GET\",\n      `/v1/agents/${encodeURIComponent(options.agentId)}`,\n    );\n    assertSafeManagedAgent(agent);\n    assertManagedAgentModel(agent, options.model);\n    return agent;\n  }\n\n  const existing = resourceByProfile(\n    await listAll(key, \"/v1/agents\"),\n    options.profileKey,\n    \"Agent\",\n  );\n  if (existing) {\n    assertSafeManagedAgent(existing);\n    assertManagedAgentModel(existing, options.model);\n    return existing;\n  }\n  if (options.probe) throw new Error(\"Probe found no matching Anthropic Agent\");\n\n  const agent = await anthropicRequest(key, \"POST\", \"/v1/agents\", {\n    name: `Paperclip · ${options.displayName}`,\n    description: \"Versioned Paperclip remote agent; runnerd supplies session tools.\",\n    model: options.model,\n    system: CLAUDE_MANAGED_SYSTEM_PROMPT,\n    tools: [],\n    mcp_servers: [],\n    skills: [],\n    metadata: { paperclip_profile: options.profileKey },\n  });\n  assertSafeManagedAgent(agent);\n  assertManagedAgentModel(agent, options.model);\n  return agent;\n}\n\nfunction assertManagedAgentModel(agent: Record<string, unknown>, expectedModel: string): void {\n  const model = typeof agent.model === \"string\" ? agent.model : record(agent.model).id;","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/cli/src/commands/managed-agent.ts#L276-L312","documentation":"resolveAgent finds a Paperclip-managed Anthropic Agent (by explicit agentId or by profile metadata). In probe mode it is forbidden to create resources, so when no matching agent exists it throws instead of POSTing /v1/agents. It signals that the remote managed agent has not been provisioned for this profile.","triggerScenarios":"Calling the `agent` (or `environment`) command with options.probe=true when no agentId is given and listAll(key, \"/v1/agents\") contains no entry whose paperclip_profile metadata equals options.profileKey.","commonSituations":"First-time setup with --probe; switched to a new Anthropic API key/workspace; agent renamed, archived, or its metadata.paperclip_profile edited outside Paperclip; agent deleted in the Anthropic console.","solutions":["Run setup without --probe once to create the managed Agent.","Pass the existing agent's ID explicitly via the agentId option.","Verify the API key/workspace contains the agent (GET /v1/agents) and its metadata.paperclip_profile matches.","If the agent was mutated externally, fix or recreate it in a non-probe run."],"exampleFix":"// before (probe on unprovisioned profile)\ncli managed-agent agent --probe\n// after\ncli managed-agent agent                # creates Agent + Environment\ncli managed-agent agent --probe        # probe now succeeds","handlingStrategy":"validation","validationCode":"// pre-check agent existence before a probe run\nconst agents = await listAll(key, \"/v1/agents\");\nif (!resourceByProfile(agents, profileKey, \"Agent\")) {\n  console.warn(\"No managed agent for profile; run setup without --probe first.\");\n}","typeGuard":"function isManagedAgent(a: unknown): a is { id: string; model: unknown; metadata?: { paperclip_profile?: string } } {\n  return typeof a === \"object\" && a !== null && typeof (a as any).id === \"string\";\n}","tryCatchPattern":"try {\n  await resolveAgent(key, { ...opts, probe: true });\n} catch (e) {\n  if (e instanceof Error && e.message === \"Probe found no matching Anthropic Agent\") {\n    // fall back to provisioning\n    await setupManagedAgent({ ...opts, probe: false });\n  } else throw e;\n}","preventionTips":["Run non-probe setup once per profile before scripting probe checks.","Persist agentId after creation and pass it explicitly thereafter.","Avoid switching API keys between setup and verification.","Watch for externally archived/deleted agents in the Anthropic console."],"tags":["probe","dry-run","anthropic","agent","not-found"],"backgroundTag":"probe-found-no-matching-resource","analyzedSha":"5716fe907e596ce73501408fc6efdb19fb61edf2","analyzedAt":"2026-09-02T18:44:00.616Z","contentChangedAt":"2026-09-02T18:44:00.616Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}