Skip to content

Commit 25ec8e8

Browse files
committed
fix: allow more attachments within the existing image payload budget
1 parent 93e414e commit 25ec8e8

7 files changed

Lines changed: 47 additions & 46 deletions

File tree

‎apps/mobile/src/lib/composerFiles.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,12 @@ describe("composer file attachments", () => {
478478
mocks.pickMedia.mockResolvedValue({ canceled: false, assets: [image, video] });
479479

480480
const result = await pickComposerMedia({
481-
existingCount: 19,
481+
existingCount: 99,
482482
maxVideoBytes: 50 * 1024 * 1024,
483483
});
484484

485485
expect(result.attachments).toEqual([expect.objectContaining({ type: "image" })]);
486-
expect(result.error).toBe("You can attach up to 20 attachments per message.");
486+
expect(result.error).toBe("You can attach up to 100 attachments per message.");
487487
expect(mocks.pickMedia).toHaveBeenCalledWith(expect.objectContaining({ selectionLimit: 1 }));
488488
expect(mocks.copy).not.toHaveBeenCalled();
489489
});
@@ -628,9 +628,9 @@ describe("composer file attachments", () => {
628628
});
629629

630630
it("does not open the picker when the draft has no remaining attachment slots", async () => {
631-
await expect(pickComposerFiles({ existingCount: 20 })).resolves.toEqual({
631+
await expect(pickComposerFiles({ existingCount: 100 })).resolves.toEqual({
632632
files: [],
633-
error: "You can attach up to 20 files per message.",
633+
error: "You can attach up to 100 files per message.",
634634
});
635635

636636
expect(mocks.pickFile).not.toHaveBeenCalled();
@@ -841,7 +841,7 @@ describe("composer file attachments", () => {
841841
],
842842
});
843843

844-
const result = await pickComposerFiles({ existingCount: 19, maxBytes: 1024 * 1024 });
844+
const result = await pickComposerFiles({ existingCount: 99, maxBytes: 1024 * 1024 });
845845

846846
expect(result.files.map((file) => file.name)).toEqual(["report.pdf"]);
847847
});

‎apps/mobile/src/state/use-composer-drafts.test.ts‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ describe("mobile composer drafts", () => {
676676
return undefined;
677677
});
678678
const key = "environment-1:replace-file";
679-
const files = Array.from({ length: 20 }, (_, index) => ({
679+
const files = Array.from({ length: 100 }, (_, index) => ({
680680
id: `file-${index}`,
681681
type: "file" as const,
682682
name: `notes-${index}.txt`,
@@ -687,8 +687,8 @@ describe("mobile composer drafts", () => {
687687
appendComposerDraftAttachments(key, files, { appendReference: true });
688688
const firstLink = "[notes-0.txt](t3-context://v1/file/file-0)";
689689
const insertion = captureComposerDraftInsertion(key, { start: 0, end: firstLink.length });
690-
expect(countComposerDraftAttachmentsAfterSelection(key, insertion)).toBe(19);
691-
expect(getComposerDraftAfterSelection(key, insertion).context?.records).toHaveLength(19);
690+
expect(countComposerDraftAttachmentsAfterSelection(key, insertion)).toBe(99);
691+
expect(getComposerDraftAfterSelection(key, insertion).context?.records).toHaveLength(99);
692692
const replacement = { ...files[0]!, id: "replacement", fileUri: "file:///replacement.txt" };
693693
if (kind === "attachment") {
694694
expect(
@@ -716,7 +716,7 @@ describe("mobile composer drafts", () => {
716716
insertion,
717717
),
718718
).toBe(true);
719-
expect(getComposerDraftSnapshot(key).attachments).toHaveLength(20);
719+
expect(getComposerDraftSnapshot(key).attachments).toHaveLength(100);
720720
expect(getComposerDraftSnapshot(key).context?.records).toContainEqual(record);
721721
expect(getComposerDraftSnapshot(key).text).toBe(
722722
`${formatComposerContextReference(record)}${insertion.text.slice(firstLink.length)}`,
@@ -730,7 +730,7 @@ describe("mobile composer drafts", () => {
730730
}
731731
const draft = getComposerDraftSnapshot(key);
732732
expect(draft.attachments.map((file) => file.id)).not.toContain("file-0");
733-
expect(draft.attachments.slice(0, 19)).toEqual(files.slice(1));
733+
expect(draft.attachments.slice(0, 99)).toEqual(files.slice(1));
734734
expect(draft.context?.records.some((record) => record.contextId === "file-0")).toBe(false);
735735
await cleanup.promise;
736736
expect(composerAttachmentCleanupMocks.remove).toHaveBeenCalledWith(files[0]!.fileUri);
@@ -746,7 +746,7 @@ describe("mobile composer drafts", () => {
746746
return undefined;
747747
});
748748
const key = "environment-1:concurrent-import";
749-
const files = Array.from({ length: 20 }, (_, index) => ({
749+
const files = Array.from({ length: 100 }, (_, index) => ({
750750
id: `existing-${index}`,
751751
type: "file" as const,
752752
name: `notes-${index}.txt`,
@@ -906,7 +906,7 @@ describe("mobile composer drafts", () => {
906906
fileUri: `file:///documents/t3-composer-attachments/${id}.mov`,
907907
});
908908
const draftKey = "new-task:environment-1:project-cap";
909-
const existing = Array.from({ length: 19 }, (_, index) => makeAttachment(`held-${index}`));
909+
const existing = Array.from({ length: 99 }, (_, index) => makeAttachment(`held-${index}`));
910910
appAtomRegistry.set(composerDraftsAtom, {
911911
[draftKey]: { text: "send this", attachments: existing },
912912
});
@@ -918,7 +918,7 @@ describe("mobile composer drafts", () => {
918918

919919
expect(rejected).toBe(1);
920920
const draft = appAtomRegistry.get(composerDraftsAtom)[draftKey];
921-
expect(draft?.attachments).toHaveLength(20);
921+
expect(draft?.attachments).toHaveLength(100);
922922
expect(draft?.attachments.at(-1)?.id).toBe("incoming-1");
923923
await cleanup.promise;
924924
expect(composerAttachmentCleanupMocks.remove).toHaveBeenCalledExactlyOnceWith(
@@ -932,7 +932,7 @@ describe("mobile composer drafts", () => {
932932
{ allowOverflow: true },
933933
);
934934
expect(overflowRejected).toBe(0);
935-
expect(appAtomRegistry.get(composerDraftsAtom)[draftKey]?.attachments).toHaveLength(21);
935+
expect(appAtomRegistry.get(composerDraftsAtom)[draftKey]?.attachments).toHaveLength(101);
936936
});
937937

938938
it("keeps shared attachment files until every draft releases them", async () => {
@@ -2270,17 +2270,17 @@ describe("mobile composer drafts", () => {
22702270
previewUri: "data:image/png;base64,YWJj",
22712271
});
22722272
const existingImage = image("existing");
2273-
const sharedImages = Array.from({ length: 20 }, (_, index) => image(`shared-${index}`));
2273+
const sharedImages = Array.from({ length: 100 }, (_, index) => image(`shared-${index}`));
22742274

22752275
const merged = mergeComposerDraftContentState(
22762276
{ [draftKey]: { text: "", attachments: [existingImage] } },
22772277
draftKey,
22782278
{ text: "", attachments: sharedImages },
22792279
);
22802280

2281-
expect(merged[draftKey]?.attachments).toHaveLength(20);
2281+
expect(merged[draftKey]?.attachments).toHaveLength(100);
22822282
expect(merged[draftKey]?.attachments[0]).toEqual(existingImage);
2283-
expect(merged[draftKey]?.attachments.at(-1)?.id).toBe("shared-18");
2283+
expect(merged[draftKey]?.attachments.at(-1)?.id).toBe("shared-98");
22842284
});
22852285

22862286
it("restores the exact draft captured before an interrupted share import", () => {

‎apps/server/src/orchestration/Normalizer.attachments.test.ts‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,22 @@ function turnStartCommand(input: {
6060
}
6161

6262
describe("normalizeDispatchCommand attachments", () => {
63-
it.effect("accepts 20 inline images and rejects 21 before writing files", () =>
63+
it.effect("accepts 100 inline images and rejects 101 before writing files", () =>
6464
Effect.gen(function* () {
6565
const config = yield* ServerConfig.ServerConfig;
66-
const attachments = Array.from({ length: 20 }, () => ({
66+
const attachments = Array.from({ length: 100 }, () => ({
6767
dataUrl: "data:image/png;base64,cGl4ZWxz",
6868
sizeBytes: 6,
6969
}));
7070
const rejected = yield* normalizeDispatchCommand(
7171
turnStartCommand({ attachments: [...attachments, attachments[0]!] }),
7272
).pipe(Effect.flip);
73-
expect(rejected.message).toContain("up to 20");
73+
expect(rejected.message).toContain("up to 100");
7474
expect(NodeFS.readdirSync(config.attachmentsDir)).toEqual([]);
7575
const accepted = yield* normalizeDispatchCommand(turnStartCommand({ attachments }));
7676
if (accepted.type !== "thread.turn.start") throw new Error("Wrong command");
77-
expect(accepted.message.attachments).toHaveLength(20);
78-
expect(NodeFS.readdirSync(config.attachmentsDir)).toHaveLength(20);
77+
expect(accepted.message.attachments).toHaveLength(100);
78+
expect(NodeFS.readdirSync(config.attachmentsDir)).toHaveLength(100);
7979
}).pipe(Effect.provide(testLayer)),
8080
);
8181

@@ -87,8 +87,7 @@ describe("normalizeDispatchCommand attachments", () => {
8787
const dataUrl = `data:image/png;base64,${Buffer.alloc(10 * 1024 * 1024).toString("base64")}`;
8888
const command = turnStartCommand({
8989
attachments: [
90-
{ dataUrl, sizeBytes: 1 },
91-
{ dataUrl, sizeBytes: 1 },
90+
...Array.from({ length: 8 }, () => ({ dataUrl, sizeBytes: 1 })),
9291
{ dataUrl: "data:image/png;base64,YQ==", sizeBytes: 0 },
9392
],
9493
});
@@ -102,8 +101,8 @@ describe("normalizeDispatchCommand attachments", () => {
102101
}),
103102
Effect.flip,
104103
);
105-
expect(error.message).toContain("20 MiB");
106-
expect(writtenBytes).toBe(20 * 1024 * 1024);
104+
expect(error.message).toContain("80 MiB");
105+
expect(writtenBytes).toBe(80 * 1024 * 1024);
107106
expect(NodeFS.readdirSync(config.attachmentsDir)).toEqual([]);
108107
}).pipe(Effect.provide(testLayer)),
109108
);
@@ -513,25 +512,25 @@ describe("question attachments", () => {
513512
answers: { first: "", second: "" },
514513
createdAt: "2026-08-01T00:00:00.000Z",
515514
attachmentsByQuestionId: {
516-
first: Array.from({ length: 10 }, () => attachment),
517-
second: Array.from({ length: 11 }, () => attachment),
515+
first: Array.from({ length: 50 }, () => attachment),
516+
second: Array.from({ length: 51 }, () => attachment),
518517
},
519518
};
520519
const failure = yield* normalizeDispatchCommand(command).pipe(Effect.flip);
521-
expect(failure.message).toContain("up to 20");
520+
expect(failure.message).toContain("up to 100");
522521
expect(NodeFS.readdirSync(config.attachmentsDir)).toEqual([`${id}.txt`]);
523522
const accepted = {
524523
...command,
525524
attachmentsByQuestionId: {
526525
...command.attachmentsByQuestionId,
527-
second: Array.from({ length: 10 }, () => attachment),
526+
second: Array.from({ length: 50 }, () => attachment),
528527
},
529528
};
530529
const normalized = yield* normalizeDispatchCommand(accepted);
531530
if (normalized.type !== "thread.user-input.respond") throw new Error("Wrong command");
532531
const attachments = Object.values(normalized.attachmentsByQuestionId!).flat();
533-
expect(attachments).toHaveLength(20);
534-
expect(new Set(attachments.map((item) => item.id)).size).toBe(20);
532+
expect(attachments).toHaveLength(100);
533+
expect(new Set(attachments.map((item) => item.id)).size).toBe(100);
535534
for (const item of attachments) {
536535
expect(item.name).toBe(attachment.name);
537536
expect(

‎docs/user/composer.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ to keep a large paste editable in the composer instead.
1414

1515
## Attach files
1616

17-
Attach up to 20 files per message. Each image can be up to 10 MiB, with at most
18-
20 MiB of images in one message. Other files, including videos, can be up to
17+
Attach up to 100 files per message. Each image can be up to 10 MiB, with at most
18+
80 MiB of images in one message. Other files, including videos, can be up to
1919
50 MiB each, subject to the environment's upload support and limit. The agent
2020
receives them on the environment's machine. Provider and model limits still
2121
apply, including images already in the conversation. A video attachment gives

‎docs/user/question-attachments.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Each question keeps its own attachments as you move between questions. Your norm
66

77
Files upload to the environment running the thread, including remote environments. The agent receives paths to those saved files with your answer and can open them with its available tools. Questions that only accept predefined choices do not offer attachments. Older servers need updating before this option appears.
88

9-
Submitted attachments remain in the thread history. Reverting a thread removes attachments belonging to discarded answers; deleting the thread uses the same file cleanup as other attachments. You can attach up to 20 files across one set of answers, using the same file and total image size limits as the normal composer.
9+
Submitted attachments remain in the thread history. Reverting a thread removes attachments belonging to discarded answers; deleting the thread uses the same file cleanup as other attachments. You can attach up to 100 files across one set of answers, using the same file and total image size limits as the normal composer.

‎packages/contracts/src/orchestration.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ export const ProviderUserInputAnswers = Schema.Record(Schema.String, Schema.Unkn
163163
export type ProviderUserInputAnswers = typeof ProviderUserInputAnswers.Type;
164164

165165
export const PROVIDER_SEND_TURN_MAX_INPUT_CHARS = 120_000;
166-
export const PROVIDER_SEND_TURN_MAX_ATTACHMENTS = 20;
166+
export const PROVIDER_SEND_TURN_MAX_ATTACHMENTS = 100;
167167
export const PROVIDER_SEND_TURN_MAX_IMAGE_BYTES = 10 * 1024 * 1024;
168-
const PROVIDER_SEND_TURN_MAX_TOTAL_IMAGE_BYTES = 20 * 1024 * 1024;
168+
const PROVIDER_SEND_TURN_MAX_TOTAL_IMAGE_BYTES = 80 * 1024 * 1024;
169169
export const PROVIDER_SEND_TURN_MAX_FILE_BYTES = 50 * 1024 * 1024;
170170
export const PROVIDER_SEND_TURN_SUPPORTED_IMAGE_MIME_TYPES = [
171171
"image/gif",
@@ -387,7 +387,7 @@ export function getProviderAttachmentLimitError(
387387
0,
388388
);
389389
if (imageBytes > PROVIDER_SEND_TURN_MAX_TOTAL_IMAGE_BYTES) {
390-
return "Images can total up to 20 MiB per message or question response. Use smaller images or send fewer at once.";
390+
return "Images can total up to 80 MiB per message or question response. Use smaller images or send fewer at once.";
391391
}
392392
}
393393

‎packages/contracts/src/provider.test.ts‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ describe("ProviderSessionStartInput", () => {
121121
});
122122

123123
describe("ProviderSendTurnInput", () => {
124-
it("accepts 20 attachments and rejects 21", () => {
125-
const attachments = Array.from({ length: 20 }, (_, index) => ({
124+
it("accepts 100 attachments and rejects 101", () => {
125+
const attachments = Array.from({ length: 100 }, (_, index) => ({
126126
type: "image",
127127
id: `image-${index}`,
128128
name: "image.png",
@@ -131,7 +131,7 @@ describe("ProviderSendTurnInput", () => {
131131
}));
132132
expect(
133133
decodeProviderSendTurnInput({ threadId: "thread-1", attachments }).attachments,
134-
).toHaveLength(20);
134+
).toHaveLength(100);
135135
expect(() =>
136136
decodeProviderSendTurnInput({
137137
threadId: "thread-1",
@@ -158,15 +158,17 @@ describe("ProviderSendTurnInput", () => {
158158
sizeBytes: 50 * 1024 * 1024,
159159
};
160160
expect(
161-
decodeProviderSendTurnInput({ threadId: "thread-1", attachments: [image, image, video] })
162-
.attachments,
163-
).toHaveLength(3);
161+
decodeProviderSendTurnInput({
162+
threadId: "thread-1",
163+
attachments: [...Array.from({ length: 8 }, () => image), video],
164+
}).attachments,
165+
).toHaveLength(9);
164166
expect(() =>
165167
decodeProviderSendTurnInput({
166168
threadId: "thread-1",
167-
attachments: [image, image, { ...image, sizeBytes: 1 }],
169+
attachments: [...Array.from({ length: 8 }, () => image), { ...image, sizeBytes: 1 }],
168170
}),
169-
).toThrow(/20 MiB/);
171+
).toThrow(/80 MiB/);
170172
},
171173
);
172174

0 commit comments

Comments
 (0)