{"record":{"id":"e34a8296cfd529d2","repo":"paperclipai/paperclip","slug":"run-inactive","errorCode":"run_inactive","errorMessage":"Run is not active","messagePattern":"Run is not active","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":403,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":1499,"sourceCode":"      .where(eq(heartbeatRuns.id, input.runId))\n      .limit(1);\n\n    if (!run || run.companyId !== input.companyId) {\n      throw new ToolGatewayHttpError(\n        403,\n        \"Run does not belong to company\",\n        \"run_company_mismatch\",\n      );\n    }\n    if (run.agentId !== input.agentId) {\n      throw new ToolGatewayHttpError(\n        403,\n        \"Run does not belong to agent\",\n        \"run_agent_mismatch\",\n      );\n    }\n    if (!ACTIVE_GATEWAY_RUN_STATUSES.has(run.status)) {\n      throw new ToolGatewayHttpError(403, \"Run is not active\", \"run_inactive\");\n    }\n\n    const snapshot = asRecord(run.contextSnapshot);\n    const snapshotIssueId = stringValue(snapshot?.issueId);\n    const snapshotProjectId = stringValue(snapshot?.projectId);\n    if (\n      (input.issueId && snapshotIssueId && input.issueId !== snapshotIssueId) ||\n      (input.projectId &&\n        snapshotProjectId &&\n        input.projectId !== snapshotProjectId)\n    ) {\n      throw new ToolGatewayHttpError(\n        403,\n        \"Supplied run context does not match stored heartbeat context\",\n        \"run_context_mismatch\",\n      );\n    }\n    const issueId = snapshotIssueId ?? input.issueId ?? null;","sourceCodeStart":1481,"sourceCodeEnd":1517,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/tool-gateway.ts#L1481-L1517","documentation":"Lifecycle guard after the ownership checks: the run's status is not active, so tool calls against it are refused (only in-flight runs may use the tool gateway). The finished/cancelled run is at fault.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:1069 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The run has ended. Start a new run/heartbeat before invoking tools; check run status first."],"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"}