fix: cap inline prompt documents, raise Discord upload cap to 10 MiB
joke-app finalize failed with "Prompt is too long (~1.18M tokens)": the runner inlined a 162-page, 8.3 MB PDF as a base64 document block for every [Document: ...] reference, and the prompt referenced it twice. The Claude runner now inlines a document at most once per prompt, only PDFs up to 20 pages / 10 MiB (512 KiB when the page count is unknown) with at most 40 PDF pages per prompt, and text documents up to 256 KiB. Larger ones become a path note telling the agent to use the Read tool. The same PDF was also rejected as an outbound attachment by our local 8 MiB cap, although Discord's default per-file limit is now 10 MiB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -359,7 +359,13 @@ describe('validateOutboundAttachments policy checks', () => {
|
||||
const largePng = writeFile(
|
||||
dir,
|
||||
'large.png',
|
||||
Buffer.concat([ONE_PIXEL_PNG, Buffer.alloc(8 * 1024 * 1024)]),
|
||||
Buffer.concat([ONE_PIXEL_PNG, Buffer.alloc(10 * 1024 * 1024)]),
|
||||
);
|
||||
// Over the old 8 MiB cap but under Discord's 10 MiB limit.
|
||||
const mediumPng = writeFile(
|
||||
dir,
|
||||
'medium.png',
|
||||
Buffer.concat([ONE_PIXEL_PNG, Buffer.alloc(8.5 * 1024 * 1024)]),
|
||||
);
|
||||
|
||||
expect(validateOutboundAttachments([{ path: nestedDir }])).toEqual({
|
||||
@@ -370,6 +376,9 @@ describe('validateOutboundAttachments policy checks', () => {
|
||||
files: [],
|
||||
rejected: [{ path: largePng, reason: 'too-large' }],
|
||||
});
|
||||
const medium = validateOutboundAttachments([{ path: mediumPng }]);
|
||||
expect(medium.rejected).toEqual([]);
|
||||
expect(medium.files).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -16,7 +16,10 @@ export interface ValidateOutboundAttachmentsResult {
|
||||
rejected: Array<{ path: string; reason: string }>;
|
||||
}
|
||||
|
||||
const MAX_ATTACHMENT_BYTES = 8 * 1024 * 1024;
|
||||
// Discord's per-file upload limit for servers without boosts has been 10 MiB
|
||||
// since 2024 (it was 8 MiB before). An 8.3 MiB PDF was rejected locally under
|
||||
// the old 8 MiB cap even though Discord would have accepted it.
|
||||
export const MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;
|
||||
const IMAGE_EXTS = /\.(png|jpe?g|gif|webp|bmp)$/i;
|
||||
const SUPPORTED_ATTACHMENT_MIMES: Record<string, string> = {
|
||||
'.png': 'image/png',
|
||||
@@ -272,7 +275,7 @@ const REJECTION_REASON_LABELS: Record<string, string> = {
|
||||
'not-found': '파일을 찾을 수 없음',
|
||||
'not-absolute': '절대경로가 아님',
|
||||
'not-file': '파일이 아님',
|
||||
'too-large': '8MB 용량 초과',
|
||||
'too-large': `${MAX_ATTACHMENT_BYTES / (1024 * 1024)}MB 용량 초과`,
|
||||
'unsupported-extension': '지원하지 않는 형식',
|
||||
'invalid-image-signature': '이미지 형식 손상 또는 불일치',
|
||||
'invalid-file-signature': '파일 형식 손상 또는 불일치',
|
||||
|
||||
Reference in New Issue
Block a user