{"record":{"id":"54e4be9770bc2474","repo":"paperclipai/paperclip","slug":"run-agent-mismatch","errorCode":"run_agent_mismatch","errorMessage":"Run does not belong to agent","messagePattern":"Run does not belong to agent","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":403,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":1084,"sourceCode":"        catalogEntryId: catalogEntry.id,\n        transport: connection.transport,\n        gatewayToolName,\n        upstreamToolName: catalogEntry.toolName,\n        catalogName: catalogEntry.name,\n        inputSchema,\n        outputSchema,\n        annotations,\n        risk: {\n          level: catalogEntry.riskLevel,\n          isReadOnly: catalogEntry.isReadOnly,\n          isWrite: catalogEntry.isWrite,\n          isDestructive: catalogEntry.isDestructive,\n        },\n        onDemandTools,\n      };\n      return {\n        name: gatewayToolName,\n        displayName: catalogEntry.title ?? catalogEntry.toolName,\n        description: catalogEntry.description ?? `Connected MCP tool ${catalogEntry.toolName} from ${connection.name}.`,\n        parametersSchema: inputSchema,\n        pluginId: `mcp:${applicationKey ?? application.id}`,\n        providerType: connection.transport === \"local_stdio\" ? \"mcp_local_stdio\" : \"mcp_remote_http\",\n        risk,\n        applicationId: application.id,\n        applicationKey,\n        applicationDisplayName: application.name,\n        connectionId: connection.id,\n        catalogEntryId: catalogEntry.id,\n        upstreamToolName: catalogEntry.toolName,\n        providerMetadata,\n      };\n    });\n  }\n\n  async function connectedMcpToolsForConnection(companyId: string, connectionId: string): Promise<ToolGatewayDescriptor[]> {\n    return (await connectedMcpToolsForCompany(companyId))","sourceCodeStart":1066,"sourceCodeEnd":1102,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/tool-gateway.ts#L1066-L1102","documentation":"Ownership guard following the company check: the run exists in the right company but belongs to a different agent than the caller. Prevents agents from reading or attaching to other agents' runs; the mismatched agentId/run pair is at fault.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:1066 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a run that belongs to the calling agent; an agent cannot act on runs of other agents."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}