{"record":{"id":"5ff6805422922972","repo":"paperclipai/paperclip","slug":"session-run-inactive","errorCode":"session_run_inactive","errorMessage":"Tool gateway session is expired or invalid","messagePattern":"Tool gateway session is expired or invalid","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":401,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":1565,"sourceCode":"      if (!project || project.companyId !== input.companyId) {\n        throw new ToolGatewayHttpError(\n          403,\n          \"Project context is outside the run company\",\n          \"run_context_mismatch\",\n        );\n      }\n    }\n    return {\n      issueId,\n      projectId,\n    };\n  }\n\n  async function writeAudit(input: {\n    session?: ToolGatewaySession | null;\n    companyId: string;\n    agentId: string | null;\n    runId: string | null;\n    issueId: string | null;\n    actorType?: LogActivityInput[\"actorType\"];\n    actorId?: string;\n    action: string;\n    details: Record<string, unknown>;\n  }) {\n    const dedicatedAuditAction =\n      input.action === \"tool_gateway.discovery\"\n        ? \"discovery\"\n        : input.action === \"tool_gateway.session_revoked\"\n          ? \"session_revoked\"\n          : input.action === \"tool_gateway.call_allowed\" ||\n              input.action === \"tool_gateway.session_created\"\n            ? \"policy_decision\"\n            : input.action === \"tool_gateway.call_completed\"\n              ? \"call_completed\"\n              : input.action === \"tool_gateway.call_denied\" ||\n                  input.action === \"tool_gateway.session_rejected\"","sourceCodeStart":1547,"sourceCodeEnd":1583,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/tool-gateway.ts#L1547-L1583","documentation":"assertSessionRunIsActive found that the heartbeat run backing a gateway session no longer exists, changed company/agent ownership, or left ACTIVE_GATEWAY_RUN_STATUSES. The session is recorded as an auth failure (session_run_inactive) and rejected because tool calls may only flow while their originating run is active.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:1249 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-establish the tool gateway session (re-authenticate); the session token expired or is invalid."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}