paperclipai/paperclip · error

Multiple Anthropic ${resourceLabel} resources use Paperclip

Error message

Multiple Anthropic ${resourceLabel} resources use Paperclip profile ${profileKey}; pass an explicit resource ID

What it means

When no explicit resource id is given, `resourceByProfile` finds Anthropic Environments/Agents by matching the `paperclip_profile` metadata key against the profile key. If two or more remote resources carry the same profile key, the lookup is ambiguous, so it throws and asks you to pass an explicit resource ID. This prevents setup from mutating or adopting the wrong resource.

Source

Thrown at cli/src/commands/managed-agent.ts:166

    page = typeof response.next_page === "string" && response.next_page
      ? response.next_page
      : null;
  } while (page);
  return rows;
}

function resourceByProfile(
  resources: RemoteResource[],
  profileKey: string,
  resourceLabel: string,
): RemoteResource | null {
  const matches = resources.filter(
    (resource) =>
      typeof resource.id === "string"
      && record(resource.metadata).paperclip_profile === profileKey,
  );
  if (matches.length > 1) {
    throw new Error(
      `Multiple Anthropic ${resourceLabel} resources use Paperclip profile ${profileKey}; pass an explicit resource ID`,
    );
  }
  return matches[0] ?? null;
}

export function assertSafeManagedEnvironment(environment: Record<string, unknown>): void {
  const config = record(environment.config);
  const networking = record(config.networking);
  const packages = record(config.packages);
  const installed = Object.entries(packages)
    .filter(([key]) => key !== "type")
    .flatMap(([, value]) => (Array.isArray(value) ? value : [value]))
    .filter((value) => value !== undefined && value !== null);
  if (
    environment.archived_at !== null
    || config.type !== "cloud"
    || networking.type !== "limited"

View on GitHub (pinned to 5716fe907e)

Solutions

  1. Pass the explicit id flag (--environment-id / --agent-id) naming the resource you want to use
  2. List the Anthropic resources (via API/console) and delete the duplicate, keeping one with metadata.paperclip_profile = <profileKey>
  3. Remove the stale duplicate's paperclip_profile metadata so only one matches
  4. Going forward, use unique profile keys per project and avoid concurrent setup runs with the same key

Example fix

// before
paperclip managed-agent setup --profile-key acme ...
// after (explicit id)
paperclip managed-agent setup --profile-key acme --environment-id 5c1f... --agent-id a9b2... ...
Defensive patterns

Strategy: validation

Validate before calling

// Before running setup without explicit ids, check the profile is unambiguous:
const resources = await listAll(key, "/v1/environments");
const matches = resources.filter(r => r.metadata?.paperclip_profile === profileKey);
if (matches.length > 1) throw new Error(`Duplicate profile ${profileKey}: ${matches.map(r => r.id).join(", ")}`);

Try / catch

try {
  await setupManagedAgent(opts);
} catch (err) {
  if (err instanceof Error && err.message.includes("Multiple Anthropic")) {
    console.error("List resources, delete/archive duplicates, or pass explicit --environment-id/--agent-id"); process.exitCode = 2;
  } else throw err;
}

Prevention

When it happens

Trigger: Running setup twice with the same --profile-key in a way that created duplicate Environments or Agents (e.g. a first run partially failed after creating the resource but before recording it locally); manually copying an existing resource's metadata.paperclip_profile; running setup concurrently from two shells with the same profile key.

Common situations: Retrying setup after a network failure mid-run without knowing the first resource was created; reusing a profile key across projects; cleaning up in the Anthropic console by cloning resources and forgetting to change the metadata tag.

Related errors


AI-assisted analysis of paperclipai/paperclip@5716fe907e (2026-09-02). Data as JSON: /api/errors/203e69da41fe1141. Report an issue: GitHub.