{"record":{"id":"29f9f095ca4cf220","repo":"Significant-Gravitas/AutoGPT","slug":"chat-export-exceeded-export-max-pages-export-p","errorCode":null,"errorMessage":"Chat export exceeded ${EXPORT_MAX_PAGES * EXPORT_PAGE_SIZE} messages. Please contact support to export this chat.","messagePattern":"Chat export exceeded (.+?) messages\\. Please contact support to export this chat\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"autogpt_platform/frontend/src/app/(platform)/copilot/helpers/exportChatAsMarkdown.ts","lineNumber":119,"sourceCode":"      throw new Error(`Failed to fetch session (status: ${response.status})`);\n    }\n\n    const pageMessages = (response.data.messages ??\n      []) as unknown as SessionChatMessage[];\n    allMessages.unshift(...pageMessages);\n\n    const hasMore = !!response.data.has_more_messages;\n    const oldestSeq = response.data.oldest_sequence;\n    if (!hasMore || oldestSeq == null) break;\n    if (page === EXPORT_MAX_PAGES - 1) {\n      truncated = true;\n      break;\n    }\n    beforeSequence = oldestSeq;\n  }\n\n  if (truncated) {\n    throw new Error(\n      `Chat export exceeded ${EXPORT_MAX_PAGES * EXPORT_PAGE_SIZE} messages. Please contact support to export this chat.`,\n    );\n  }\n\n  exportChatAsMarkdown(id, title, allMessages);\n}\n","sourceCodeStart":101,"sourceCodeEnd":126,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/exportChatAsMarkdown.ts#L101-L126","documentation":"A deliberate guard, not a failure: exportChatAsMarkdown paginates backwards through a session with EXPORT_PAGE_SIZE per page and a hard cap of EXPORT_MAX_PAGES. If the loop hits the last allowed page while has_more_messages is still true, `truncated` is set and this error is thrown instead of silently producing a partial export. The count EXPORT_MAX_PAGES * EXPORT_PAGE_SIZE is the maximum exportable message count.","triggerScenarios":"Clicking Export on a copilot chat with more than EXPORT_MAX_PAGES * EXPORT_PAGE_SIZE messages; the loop consumed every page and the backend still reported has_more_messages=true with a valid oldest_sequence.","commonSituations":"Power users with months-long copilot sessions; agent loops that log hundreds of messages per run; someone lowered EXPORT_MAX_PAGES/EXPORT_PAGE_SIZE locally without realizing it caps exports.","solutions":["Export is intentionally capped — contact support / use the backend API directly to page through the full history for very long chats.","Raise EXPORT_MAX_PAGES in the constants if you self-host and accept larger exports.","Split the conversation: start a new copilot session once chats get very long.","If you believe the count is wrong, check whether the chat contains duplicate/bloated tool messages inflating the total."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { EXPORT_MAX_PAGES, EXPORT_PAGE_SIZE } from \"./exportChatAsMarkdown\";\n\nfunction isExportable(messageCount: number): boolean {\n  return messageCount <= EXPORT_MAX_PAGES * EXPORT_PAGE_SIZE;\n}","typeGuard":"function isExportTruncation(err: unknown): boolean {\n  return err instanceof Error && err.message.startsWith(\"Chat export exceeded\");\n}","tryCatchPattern":"try {\n  await exportSession(id);\n} catch (error) {\n  if (isExportTruncation(error)) {\n    // informational, not a bug: direct user to support / backend export\n    toast({ title: \"Chat too long to export\", description: error.message });\n  }\n}","preventionTips":["Surface the session's message count in the UI so users know before clicking export.","Treat this throw as a by-design guard — don't catch-and-continue; a silent partial export is worse.","For self-hosted very-long chats, provide a backend bulk-export path rather than raising the cap blindly."],"tags":["copilot","export","limit","pagination","by-design"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}