{"record":{"id":"abe6e7a3250d4518","repo":"paperclipai/paperclip","slug":"existing-anthropic-agent-model-does-not-match-the","errorCode":null,"errorMessage":"Existing Anthropic Agent model does not match the requested pinned model ${expectedModel}","messagePattern":"Existing Anthropic Agent model does not match the requested pinned model (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/managed-agent.ts","lineNumber":314,"sourceCode":"  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;\n  if (model !== expectedModel) {\n    throw new Error(\n      `Existing Anthropic Agent model does not match the requested pinned model ${expectedModel}`,\n    );\n  }\n}\n\nexport async function setupManagedAgent(options: ManagedAgentSetupOptions): Promise<void> {\n  const validated = validateManagedAgentSetup(options);\n  const normalizedOptions: ManagedAgentSetupOptions = {\n    ...options,\n    profileKey: validated.profileKey,\n    displayName: validated.displayName,\n    apiKeySecretId: validated.apiKeySecretId,\n    model: validated.model,\n    agentId: validated.agentId,\n    agentVersion: validated.agentVersion,\n    environmentId: validated.environmentId,\n  };\n  const [environment, agent] = await Promise.all([","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/cli/src/commands/managed-agent.ts#L296-L332","documentation":"assertManagedAgentModel enforces that an existing Anthropic Agent runs exactly the pinned model requested by the caller (e.g. claude-sonnet-4-5). The agent's model field (string or object with .id) must strictly equal the expected model string; any mismatch aborts setup rather than silently re-pointing the versioned agent at a different model.","triggerScenarios":"resolveAgent or setupManagedAgent encounters an agent whose returned model differs from options.model — e.g. a caller upgrades the pinned model string in config while the remote agent was created with the older model, or an --agent-id is passed whose model differs from the requested one.","commonSituations":"Changing the pinned Claude model in Paperclip settings after the agent was created; Anthropic returning a model object whose id differs from the alias you passed (alias resolution/version skew); manually editing the agent's model in the Anthropic console.","solutions":["Align the requested pinned model with the existing agent's actual model (read it from the Anthropic console or GET /v1/agents/:id).","Delete or archive the old agent and let a non-probe setup create a new one with the new model.","Pass the correct --agent-id for an agent that already matches the requested model.","Check for model alias drift — pin a concrete model id instead of a moving alias."],"exampleFix":"// before: config pins new model but remote agent is older\n{ \"model\": \"claude-sonnet-4-5\" }   // remote agent: claude-sonnet-4-20250514\n// after: either pin the actual remote model\n{ \"model\": \"claude-sonnet-4-20250514\" }\n// or recreate the agent with the new model (run without probe after removing the old one)","handlingStrategy":"validation","validationCode":"// compare before invoking setup\nconst agent = await anthropicRequest(key, \"GET\", `/v1/agents/${agentId}`);\nconst model = typeof agent.model === \"string\" ? agent.model : agent.model?.id;\nif (model !== expectedModel) {\n  console.warn(`Agent ${agentId} runs ${model}, config pins ${expectedModel} — recreate or realign.`);\n}","typeGuard":"function agentMatchesModel(agent: Record<string, unknown>, expected: string): boolean {\n  const model = typeof agent.model === \"string\" ? agent.model\n    : (typeof agent.model === \"object\" && agent.model !== null && typeof (agent.model as any).id === \"string\"\n      ? (agent.model as any).id as string : undefined);\n  return model === expected;\n}","tryCatchPattern":"try {\n  await setupManagedAgent(options);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith(\"Existing Anthropic Agent model does not match\")) {\n    // surface actionable guidance to the operator instead of a raw stack\n    throw new Error(`${e.message}. Realign the pinned model or delete/recreate the managed agent.`, { cause: e });\n  }\n  throw e;\n}","preventionTips":["Pin concrete model ids, not moving aliases.","When changing the pinned model, plan a delete-and-recreate of the managed agent.","Verify the agent's current model before re-running setup after config edits.","Keep one source of truth for the model string shared by config and setup."],"tags":["anthropic","agent","model-mismatch","configuration"],"backgroundTag":"model-mismatch","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"}