diff --git a/coderd/exp_chats_test.go b/coderd/exp_chats_test.go index 4f47e23c6a..23cb181ed9 100644 --- a/coderd/exp_chats_test.go +++ b/coderd/exp_chats_test.go @@ -7309,10 +7309,7 @@ func TestChatMessageWithFiles(t *testing.T) { // Only MaxChatFileIDs files should actually be linked. // With SQL-level batch rejection, ALL files are rejected - // when the result would exceed the cap. Since we're - // sending MaxChatFileIDs+1 files, the deduped count is - // 21 > 20, so 0 rows are affected and all files are - // unlinked. + // when the result would exceed the cap. chatResult, err := client.GetChat(ctx, chat.ID) require.NoError(t, err) require.Empty(t, chatResult.Files, "no files should be linked when batch exceeds cap") diff --git a/coderd/x/chatd/chattool/attachfile_test.go b/coderd/x/chatd/chattool/attachfile_test.go index 4230b42459..52bb41bb37 100644 --- a/coderd/x/chatd/chattool/attachfile_test.go +++ b/coderd/x/chatd/chattool/attachfile_test.go @@ -257,14 +257,14 @@ func TestAttachFile(t *testing.T) { Return(io.NopCloser(strings.NewReader("build succeeded\n")), "text/plain", nil) tool := newAttachFileTool(t, mockConn, func(_ context.Context, _ string, _ string, _ []byte) (chattool.AttachmentMetadata, error) { - return chattool.AttachmentMetadata{}, xerrors.New("chat already has the maximum of 20 linked files") + return chattool.AttachmentMetadata{}, xerrors.New("ETOOMANYFILES") }) resp, err := tool.Run(context.Background(), fantasy.ToolCall{ ID: "call-cap", Name: "attach_file", Input: `{"path":"/home/coder/build.log"}`, }) require.NoError(t, err) assert.True(t, resp.IsError) - assert.Contains(t, resp.Content, "chat already has the maximum of 20 linked files") + assert.Contains(t, resp.Content, "ETOOMANYFILES") }) } diff --git a/coderd/x/chatd/chattool/computeruse_test.go b/coderd/x/chatd/chattool/computeruse_test.go index 5138003345..ec6ba045db 100644 --- a/coderd/x/chatd/chattool/computeruse_test.go +++ b/coderd/x/chatd/chattool/computeruse_test.go @@ -273,7 +273,7 @@ func TestComputerUseTool_Run_Screenshot_StoreErrorFallsBackToImage(t *testing.T) tool := chattool.NewComputerUseTool(chattool.ComputerUseProviderAnthropic, geometry.DeclaredWidth, geometry.DeclaredHeight, func(_ context.Context) (workspacesdk.AgentConn, error) { return mockConn, nil }, func(_ context.Context, _ string, _ string, _ []byte) (chattool.AttachmentMetadata, error) { - return chattool.AttachmentMetadata{}, xerrors.New("chat already has the maximum of 20 linked files") + return chattool.AttachmentMetadata{}, xerrors.New("ETOOMANYFILES") }, quartz.NewReal(), slogtest.Make(t, nil)) resp, err := tool.Run(context.Background(), fantasy.ToolCall{ @@ -652,7 +652,7 @@ func TestComputerUseTool_Run_OpenAI_FinalScreenshotStoreErrorFallsBackToImage(t recordDesktopActions(t, mockConn, geometry, 1, screenshotPNG) tool := newOpenAIComputerUseTool(t, geometry, mockConn, func(_ context.Context, _ string, _ string, _ []byte) (chattool.AttachmentMetadata, error) { - return chattool.AttachmentMetadata{}, xerrors.New("chat already has the maximum of 20 linked files") + return chattool.AttachmentMetadata{}, xerrors.New("ETOOMANYFILES") }, quartz.NewReal()) resp, err := tool.Run(context.Background(), openAIComputerUseCall(`{ diff --git a/coderd/x/chatd/store_chat_attachment_test.go b/coderd/x/chatd/store_chat_attachment_test.go index 0bb4eb29bb..70325bd945 100644 --- a/coderd/x/chatd/store_chat_attachment_test.go +++ b/coderd/x/chatd/store_chat_attachment_test.go @@ -2,6 +2,7 @@ package chatd //nolint:testpackage import ( "context" + "fmt" "testing" "github.com/google/uuid" @@ -216,7 +217,7 @@ func TestStoreChatAttachment_StrictCapError(t *testing.T) { }).Return(int32(1), nil) attachment, err := server.storeChatAttachment(context.Background(), chatSnapshot, "build.log", "build.log", []byte("build output")) - require.ErrorContains(t, err, "chat already has the maximum of 20 linked files") + require.ErrorContains(t, err, fmt.Sprintf("chat already has the maximum of %d linked files", codersdk.MaxChatFileIDs)) require.Equal(t, chattool.AttachmentMetadata{}, attachment) } diff --git a/codersdk/chats.go b/codersdk/chats.go index 4c8706c42c..562bc0014d 100644 --- a/codersdk/chats.go +++ b/codersdk/chats.go @@ -31,7 +31,7 @@ const ChatCompactionThresholdKeyPrefix = "chat_compaction_threshold_pct:" // associated with a single chat. This limit prevents unbounded // growth in the chat_file_links table. It is easier to raise // this limit than to lower it. -const MaxChatFileIDs = 20 +const MaxChatFileIDs = 50 // MaxChatFileSizeBytes is the upload-endpoint cap for chat // attachments. diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index 75e4bb2b10..4ce4e9945b 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -5126,7 +5126,7 @@ export interface MatchedProvisioners { * growth in the chat_file_links table. It is easier to raise * this limit than to lower it. */ -export const MaxChatFileIDs = 20; +export const MaxChatFileIDs = 50; // From codersdk/chats.go /**