{"record":{"id":"8001f7d2bfb9256c","repo":"paperclipai/paperclip","slug":"agent-context-required","errorCode":"agent_context_required","errorMessage":"Paperclip self tools require an agent-scoped gateway session","messagePattern":"Paperclip self tools require an agent-scoped gateway session","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":403,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":2943,"sourceCode":"          400,\n          \"Parameters noteId and body are required\",\n          \"invalid_parameters\",\n        );\n      }\n      return {\n        content: JSON.stringify({ noteId, updated: true }),\n        data: {\n          noteId,\n          bodyLength: body.length,\n          transport: \"mcp_http\",\n          spawnedLocalProcess: false,\n        },\n      };\n    }\n\n    if (tool.name === \"paperclip-self:list_my_issues\") {\n      if (!session.agentId) {\n        throw new ToolGatewayHttpError(\n          403,\n          \"Paperclip self tools require an agent-scoped gateway session\",\n          \"agent_context_required\",\n        );\n      }\n      const limit = Math.max(1, Math.min(50, Number(params.limit ?? 10) || 10));\n      const rows = await db\n        .select({\n          id: issues.id,\n          identifier: issues.identifier,\n          title: issues.title,\n          status: issues.status,\n          priority: issues.priority,\n        })\n        .from(issues)\n        .where(\n          and(\n            eq(issues.companyId, session.companyId),","sourceCodeStart":2925,"sourceCodeEnd":2961,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/tool-gateway.ts#L2925-L2961","documentation":"paperclip-self tools (like list_my_issues / get_issue_context) are restricted to agent-identified sessions, but the current gateway session has no agentId (e.g. a user/board-issued token). The 403 agent_context_required fires before any self-tool logic runs because there is no 'self' to scope the query to.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:2022 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an agent-scoped gateway session (agent API key + run context) to call Paperclip self tools."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}