{"record":{"id":"74753f7f35cfe27d","repo":"paperclipai/paperclip","slug":"session-invalid","errorCode":"session_invalid","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":1282,"sourceCode":"    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\"\n                ? \"call_failed\"\n                : \"call_failed\";\n    const dedicatedOutcome =\n      input.action === \"tool_gateway.session_revoked\"\n        ? \"success\"\n        : input.action === \"tool_gateway.call_denied\" || input.action === \"tool_gateway.session_rejected\"\n        ? \"denied\"\n        : input.action === \"tool_gateway.call_deferred\"\n          ? \"timeout\"\n          : input.action === \"tool_gateway.call_failed\"\n            ? \"failure\"\n            : \"success\";\n    try {\n      await db.insert(toolAccessAuditEvents).values({\n        companyId: input.companyId,","sourceCodeStart":1264,"sourceCodeEnd":1300,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/tool-gateway.ts#L1264-L1300","documentation":"401 sentinel thrown after writeSessionAuthFailure logged a session_run_inactive event: the gateway session token itself is well-formed, but the run it authenticates for is no longer active, so the session is treated as expired/invalid and the client must re-authenticate against a new run.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:1264 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":"try-catch","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-14T00:17:10.932Z"}