{"record":{"id":"f55e56c4f8b86be7","repo":"paperclipai/paperclip","slug":"existing-anthropic-agent-enables-or-omits-the-lock","errorCode":null,"errorMessage":"Existing Anthropic Agent enables or omits the locked tools, MCP, skills, or multi-agent profile","messagePattern":"Existing Anthropic Agent enables or omits the locked tools, MCP, skills, or multi-agent profile","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/managed-agent.ts","lineNumber":212,"sourceCode":"  }\n}\n\nexport function assertSafeManagedAgent(agent: Record<string, unknown>): void {\n  const model = typeof agent.model === \"string\" ? agent.model : record(agent.model).id;\n  if (\n    agent.archived_at !== null\n    || agent.system !== CLAUDE_MANAGED_SYSTEM_PROMPT\n    || typeof model !== \"string\"\n    || !model\n    || !Array.isArray(agent.tools)\n    || agent.tools.length > 0\n    || !Array.isArray(agent.mcp_servers)\n    || agent.mcp_servers.length > 0\n    || !Array.isArray(agent.skills)\n    || agent.skills.length > 0\n    || agent.multiagent != null\n  ) {\n    throw new Error(\n      \"Existing Anthropic Agent enables or omits the locked tools, MCP, skills, or multi-agent profile\",\n    );\n  }\n}\n\nasync function resolveEnvironment(\n  key: string,\n  options: ManagedAgentSetupOptions,\n): Promise<Record<string, unknown>> {\n  if (options.environmentId) {\n    const environment = await anthropicRequest(\n      key,\n      \"GET\",\n      `/v1/environments/${encodeURIComponent(options.environmentId)}`,\n    );\n    assertSafeManagedEnvironment(environment);\n    return environment;\n  }","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/cli/src/commands/managed-agent.ts#L194-L230","documentation":"`assertSafeManagedAgent` verifies an existing Anthropic Agent matches Paperclip's locked profile: not archived, exact CLAUDE_MANAGED_SYSTEM_PROMPT, a non-empty model string, and empty `tools`, `mcp_servers`, and `skills` arrays with `multiagent` unset. Any deviation throws this error. It guarantees Paperclip only drives agents whose capabilities are fully locked down to session-supplied tools.","triggerScenarios":"Passing --agent-id pointing at an agent you edited in the Anthropic console to add tools, MCP servers, skills, or multi-agent config; an agent with a modified system prompt or different model; adopting a pre-existing general-purpose agent; an archived agent being reused; a beta API schema change altering defaults so fields no longer serialize as empty arrays or null.","commonSituations":"Tinkering with the agent definition to test a tool, then the next Paperclip run rejects it; pointing the CLI at an agent created outside Paperclip; version drift where the recorded CLAUDE_MANAGED_SYSTEM_PROMPT no longer matches a prompt edited remotely.","solutions":["Omit --agent-id and let Paperclip create/resolve a conforming agent automatically","Revert the agent: restore the exact Paperclip system prompt, empty tools/mcp_servers/skills arrays, remove multiagent, unarchive, and keep the qualified model","Delete the modified agent and run setup fresh so Paperclip provisions a new one","Diff the agent JSON (GET /v1/agents/:id) against the locked profile to find which field trips the assertion"],"exampleFix":"// before\n--agent-id agent_hand_modified  // has tools=[{...}], skills=[\"web\"]\n// after (let Paperclip resolve/create)\npaperclip managed-agent setup ... # no --agent-id\n// or fix the agent:\n{\"system\":\"<CLAUDE_MANAGED_SYSTEM_PROMPT>\",\"tools\":[],\"mcp_servers\":[],\"skills\":[],\"multiagent\":null,\"archived_at\":null}","handlingStrategy":"type-guard","validationCode":"// Fetch and check before passing --agent-id:\nconst agent = await getAgent(key, agentId);\nconst bad = agent.archived_at !== null || agent.tools?.length || agent.mcp_servers?.length\n  || agent.skills?.length || agent.multiagent != null || agent.system !== CLAUDE_MANAGED_SYSTEM_PROMPT;\nif (bad) throw new Error(\"Agent does not match the locked tools/MCP/skills/multiagent profile\");","typeGuard":"function isSafeAgent(agent: Record<string, unknown>): boolean {\n  const model = typeof agent.model === \"string\" ? agent.model : (agent.model as any)?.id;\n  return agent.archived_at === null && agent.system === CLAUDE_MANAGED_SYSTEM_PROMPT\n    && typeof model === \"string\" && model.length > 0\n    && Array.isArray(agent.tools) && agent.tools.length === 0\n    && Array.isArray(agent.mcp_servers) && agent.mcp_servers.length === 0\n    && Array.isArray(agent.skills) && agent.skills.length === 0\n    && agent.multiagent == null;\n}","tryCatchPattern":"try {\n  await setupManagedAgent(opts);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"locked tools, MCP, skills\")) {\n    console.error(\"Agent drifted from the locked profile — recreate via Paperclip or revert its definition\"); process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Let Paperclip create agents instead of adopting externally created ones","Don't add tools, MCP servers, skills, or multiagent config to Paperclip-managed agents in the console","Never pass --agent-id for archived agents or agents with edited system prompts","Re-assert the profile after any manual agent change or beta API update"],"tags":["safety-check","configuration-drift","anthropic-agent","profile-mismatch"],"backgroundTag":"config-profile-mismatch","analyzedSha":"5716fe907e596ce73501408fc6efdb19fb61edf2","analyzedAt":"2026-09-02T18:44:00.616Z","contentChangedAt":"2026-09-02T18:44:00.616Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}