Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(pam): skip AI summary for sessions exceeding log size limit instead of truncating

bernie-g1b7fc9c44b33
diff --git a/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.ts b/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.ts
index f2e7dfb599..2c97436587 100644
--- a/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.ts
+++ b/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.ts
@@ -238,6 +238,15 @@ export const pamSessionAiSummaryServiceFactory = ({
offset += PAGE_SIZE;
}
+ if (contentChars >= MAX_LOG_CHARS) {
+ logger.info(
+ { sessionId },
+ `${QueueName.PamSessionAiSummary}: session logs exceed size limit, skipping AI summary [sessionId=${sessionId}]`
+ );
+ await pamSessionDAL.updateById(sessionId, { aiInsightsStatus: null });
+ return;
+ }
+
if (accumulatedLogs.length > 0) {
logs = accumulatedLogs;
} else if (session.encryptedLogsBlob) {
diff --git a/backend/src/ee/services/pam-session/pam-session-summary-fns.ts b/backend/src/ee/services/pam-session/pam-session-summary-fns.ts
index 8282af1e59..3e8b19ae3b 100644
--- a/backend/src/ee/services/pam-session/pam-session-summary-fns.ts
+++ b/backend/src/ee/services/pam-session/pam-session-summary-fns.ts
@@ -17,8 +17,7 @@ export const formatLogsForSummary = (
const ts = new Date(log.timestamp).toISOString();
return `[${i + 1}] [${ts}]\nQuery: ${log.input.trim()}\nResult: ${log.output.trim()}`;
});
- const joined = lines.join("\n\n");
- return joined.length > MAX_LOG_CHARS ? `${joined.slice(0, MAX_LOG_CHARS)}\n...(truncated)` : joined;
+ return lines.join("\n\n");
}
// SSH: extract input events and decode Base64 → printable text
@@ -35,8 +34,7 @@ export const formatLogsForSummary = (
// skip malformed base64
}
}
- const combined = inputLines.join("");
- return combined.length > MAX_LOG_CHARS ? `${combined.slice(0, MAX_LOG_CHARS)}\n...(truncated)` : combined;
+ return inputLines.join("");
};
const SYSTEM_PROMPTS: Partial<Record<PamResource, string>> = {