From d97e03bd22b9133db60c881399751c0c617bf3a3 Mon Sep 17 00:00:00 2001 From: afjcjsbx Date: Wed, 18 Mar 2026 20:05:50 +0100 Subject: [PATCH] fix error message --- pkg/tools/filesystem.go | 2 +- pkg/tools/filesystem_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/tools/filesystem.go b/pkg/tools/filesystem.go index 4a4bd801f..39d45013d 100644 --- a/pkg/tools/filesystem.go +++ b/pkg/tools/filesystem.go @@ -536,7 +536,7 @@ func (t *WriteFileTool) Execute(ctx context.Context, args map[string]any) *ToolR if !overwrite { if _, err := t.fs.Open(path); err == nil { - return ErrorResult(fmt.Sprintf("file already exists: %s (set overwrite=true to replace it)", path)) + return ErrorResult(fmt.Sprintf("file: %s already exists. Set overwrite=true to replace.", path)) } } diff --git a/pkg/tools/filesystem_test.go b/pkg/tools/filesystem_test.go index 208d10984..0b4dd310b 100644 --- a/pkg/tools/filesystem_test.go +++ b/pkg/tools/filesystem_test.go @@ -203,7 +203,7 @@ func TestFilesystemTool_WriteFile_OverwriteDefaultBlocked(t *testing.T) { }) assert.True(t, result.IsError, "expected error when overwriting without overwrite=true") - assert.Contains(t, result.ForLLM, "file already exists") + assert.Contains(t, result.ForLLM, "already exists") assert.Contains(t, result.ForLLM, "overwrite=true") // Original content must be untouched @@ -267,7 +267,7 @@ func TestFilesystemTool_WriteFile_OverwriteFalseExplicitBlocked(t *testing.T) { }) assert.True(t, result.IsError, "expected error when overwrite=false") - assert.Contains(t, result.ForLLM, "file already exists") + assert.Contains(t, result.ForLLM, "already exists") data, err := os.ReadFile(testFile) assert.NoError(t, err) @@ -289,7 +289,7 @@ func TestFilesystemTool_WriteFile_OverwriteSandboxed(t *testing.T) { "content": "new content", }) assert.True(t, result.IsError, "expected error in sandbox mode without overwrite=true") - assert.Contains(t, result.ForLLM, "file already exists") + assert.Contains(t, result.ForLLM, "already exists") // With overwrite=true → allowed result = tool.Execute(context.Background(), map[string]any{