{"record":{"id":"89778d4e7ef7742e","repo":"paperclipai/paperclip","slug":"agent-key-belongs-to-agent-name-agent-id","errorCode":null,"errorMessage":"Agent key belongs to ${agent.name} (${agent.id}), not '${reference}'. Use the matching agent or a board prompt.","messagePattern":"Agent key belongs to (.+?) \\((.+?)\\), not '(.+?)'\\. Use the matching agent or a board prompt\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/client/prompt.ts","lineNumber":257,"sourceCode":"  if (!normalized) throw new Error(\"Prompt text is required\");\n  return normalized;\n}\n\nfunction defaultPromptTitle(prompt: string): string {\n  const firstLine = prompt.split(/\\r?\\n/).map((line) => line.trim()).find(Boolean) ?? \"Prompt handoff\";\n  return firstLine.length > 100 ? `${firstLine.slice(0, 97)}...` : firstLine;\n}\n\nfunction assertAgentMatchesReference(agent: Agent, reference: string): void {\n  const normalized = reference.trim().toLowerCase();\n  if (!normalized) throw new Error(\"Agent reference is required\");\n  const matches = [\n    agent.id,\n    agent.name,\n    typeof agent.urlKey === \"string\" ? agent.urlKey : null,\n  ].some((value) => value?.toLowerCase() === normalized);\n  if (!matches) {\n    throw new Error(\n      `Agent key belongs to ${agent.name} (${agent.id}), not '${reference}'. Use the matching agent or a board prompt.`,\n    );\n  }\n}\n\nfunction agentSummary(agent: Agent): PromptResult[\"agent\"] {\n  return {\n    id: agent.id,\n    name: agent.name,\n    urlKey: typeof agent.urlKey === \"string\" ? agent.urlKey : null,\n  };\n}\n\nfunction readApiKeyEnvOption(opts: PromptOptions): string | undefined {\n  if (!opts.apiKeyEnv?.trim()) return undefined;\n  const value = process.env[opts.apiKeyEnv.trim()]?.trim();\n  if (!value) throw new Error(`Environment variable ${opts.apiKeyEnv.trim()} is not set`);\n  return value;","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/cli/src/commands/client/prompt.ts#L239-L275","documentation":"assertAgentMatchesReference verified that the authenticated agent (from /agents/me) matches the requested reference across id/name/urlKey; mismatch means the agent API key belongs to a different agent than requested.","triggerScenarios":"Thrown at cli/src/commands/client/prompt.ts:257 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the API key belonging to the referenced agent, or use a board prompt instead."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}