{"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":1267,"sourceCode":"        .select({ companyId: projects.companyId })\n        .from(projects)\n        .where(eq(projects.id, projectId))\n        .limit(1);\n      if (!project || project.companyId !== input.companyId) {\n        throw new ToolGatewayHttpError(403, \"Project context is outside the run company\", \"run_context_mismatch\");\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\" || 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\" || input.action === \"tool_gateway.session_rejected\"\n              ? \"call_denied\"\n              : input.action === \"tool_gateway.call_deferred\"","sourceCodeStart":1249,"sourceCodeEnd":1285,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/tool-gateway.ts#L1249-L1285","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":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}