paperclipai/paperclip · error
Anthropic pinned Agent version identity does not match the s
Error message
Anthropic pinned Agent version identity does not match the selected Agent
What it means
After selecting the pinned version entry, setupManagedAgent verifies that the matched version record's `id` equals the resolved agentId. A mismatch means the versions endpoint returned an entry belonging to a different agent (identity drift between listing and detail), and setup refuses to attach credentials to the wrong resource.
Source
Thrown at cli/src/commands/managed-agent.ts:355
const environmentId = String(environment.id ?? "");
if (!agentId || !environmentId) {
throw new Error("Anthropic did not return usable Agent and Environment identities");
}
const versions = await listAll(
validated.anthropicApiKey,
`/v1/agents/${encodeURIComponent(agentId)}/versions`,
);
const version = normalizedOptions.agentVersion
?? String(agent.version ?? versions.at(-1)?.version ?? "");
const pinnedAgent = version
? versions.find((entry) => String(entry.version) === version)
: undefined;
if (!version || !pinnedAgent) {
throw new Error("Anthropic did not return a usable pinned Agent version");
}
if (String(pinnedAgent.id ?? "") !== agentId) {
throw new Error("Anthropic pinned Agent version identity does not match the selected Agent");
}
assertSafeManagedAgent(pinnedAgent);
assertManagedAgentModel(pinnedAgent, normalizedOptions.model);
const qualification = {
probedAt: new Date().toISOString(),
betaVersion: CLAUDE_MANAGED_BETA_VERSION,
environmentPolicy: "limited_no_hosts_no_packages",
agentCapabilities: "no_tools_no_mcp_no_skills_no_multiagent",
};
const profile = {
profileKey: normalizedOptions.profileKey,
displayName: normalizedOptions.displayName,
anthropicAgentId: agentId,
agentVersion: version,
environmentId,
defaultModel: normalizedOptions.model,
defaultMaxListCostUsd: validated.defaultMaxListCostUsd,View on GitHub (pinned to 5716fe907e)
Solutions
- Re-run setup; a transient race usually resolves once the agent identity is stable.
- Avoid deleting/recreating the agent while a setup or probe run is in flight.
- Bypass any caching proxy or verify cache keys when calling api.anthropic.com.
- Pass an explicit agentId so the detail fetch and version listing refer to the same resource.
Example fix
// before: deleting and recreating the agent during setup races the version fetch // after: serialize operations — only recreate the agent when no setup is running await setupManagedAgent(options); // then recreate // or pass a stable explicit agentId so both calls hit the same resource
Defensive patterns
Strategy: retry
Validate before calling
// detect identity drift before attaching credentials
const versions = await listAll(key, `/v1/agents/${agentId}/versions`);
const pinned = versions.find(v => String(v.version) === version);
if (pinned && String(pinned.id) !== agentId) {
console.warn("Version identity drift detected — agent changed mid-setup; rerun.");
} Type guard
function versionBelongsToAgent(v: { id?: unknown }, agentId: string): boolean {
return typeof v.id === "string" && v.id === agentId;
} Try / catch
try {
await setupManagedAgent(options);
} catch (e) {
if (e instanceof Error && e.message.includes("pinned Agent version identity does not match")) {
await sleep(1000); // let identity settle after any recreate
await setupManagedAgent(options); // single bounded retry
} else throw e;
} Prevention
- Never delete/recreate the agent concurrently with setup or probe runs.
- Serialize setup runs per profile with a lock.
- Bypass or correctly key caches on the API path.
- Pass an explicit agentId so detail and version calls reference one resource.
When it happens
Trigger: versions.find(...) returned an entry whose pinnedAgent.id differs from the resolved agent.id — typically caused by a concurrent agent recreation between the two calls, a caching proxy serving versions of another agent, or an API returning non-filtered version listings.
Common situations: Agent deleted and recreated mid-setup (ID changed while versions were fetched); misconfigured gateway cache keyed incorrectly; race between two concurrent setup runs using the same profile.
Related errors
- Probe found no matching Anthropic Agent
- Existing Anthropic Agent model does not match the requested
- Anthropic did not return a usable pinned Agent version
- ${name} must be a JSON object
- Invalid ${name} JSON: ${err instanceof Error ? err.message :
AI-assisted analysis of paperclipai/paperclip@5716fe907e (2026-09-02).
Data as JSON: /api/errors/43a98a2cc6499cf0.
Report an issue: GitHub.