mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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(`{
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
Generated
+1
-1
@@ -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
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user