fix(tool): make escape semantics descriptions provider-agnostic

Replace CLI-specific "In function.arguments" phrasing with
provider-neutral language about JSON escaping, since:
- CLI providers: function.arguments is JSON-encoded string (double decode)
- API providers (Anthropic, OpenAI, Bedrock): function.arguments is
  a JSON object directly (single decode)

This affects write_file, edit_file, and append_file tool descriptions.

Fixes #2337
This commit is contained in:
merlinmiao 2026-04-05 10:25:16 +08:00
parent 15a70ac45c
commit d2fb201fc5
2 changed files with 7 additions and 7 deletions

View file

@ -29,7 +29,7 @@ func (t *EditFileTool) Name() string {
}
func (t *EditFileTool) Description() string {
return "Edit a file by replacing old_text with new_text. The old_text must exist exactly in the file. In `function.arguments`, use \\n for newline and \\\\n for literal backslash-n."
return "Edit a file by replacing old_text with new_text. The old_text must exist exactly in the file. Standard JSON escaping applies: use `\n` for newline, `\\n` for literal backslash-n."
}
func (t *EditFileTool) Parameters() map[string]any {
@ -42,11 +42,11 @@ func (t *EditFileTool) Parameters() map[string]any {
},
"old_text": map[string]any{
"type": "string",
"description": "The exact text to find and replace. In `function.arguments`, use \\n for newline and \\\\n for literal backslash-n.",
"description": "The exact text to find and replace. Standard JSON escaping applies: use `\n` for newline, `\\n` for literal backslash-n.",
},
"new_text": map[string]any{
"type": "string",
"description": "The text to replace with. In `function.arguments`, use \\n for newline and \\\\n for literal backslash-n.",
"description": "The text to replace with. Standard JSON escaping applies: use `\n` for newline, `\\n` for literal backslash-n.",
},
},
"required": []string{"path", "old_text", "new_text"},
@ -92,7 +92,7 @@ func (t *AppendFileTool) Name() string {
}
func (t *AppendFileTool) Description() string {
return "Append content to the end of a file. In `function.arguments`, use \\n for newline and \\\\n for literal backslash-n."
return "Append content to the end of a file. Standard JSON escaping applies: use `\n` for newline, `\\n` for literal backslash-n."
}
func (t *AppendFileTool) Parameters() map[string]any {
@ -105,7 +105,7 @@ func (t *AppendFileTool) Parameters() map[string]any {
},
"content": map[string]any{
"type": "string",
"description": "The content to append. In `function.arguments`, use \\n for newline and \\\\n for literal backslash-n.",
"description": "The content to append. Standard JSON escaping applies: use `\n` for newline, `\\n` for literal backslash-n.",
},
},
"required": []string{"path", "content"},

View file

@ -870,7 +870,7 @@ func (t *WriteFileTool) Name() string {
}
func (t *WriteFileTool) Description() string {
return "Write content to a file. In `function.arguments`, use \\n for a newline and \\\\n for a literal backslash-n sequence. Content is written byte-for-byte after argument decoding. If the file already exists, you must set overwrite=true to replace it."
return "Write content to a file. Content is written byte-for-byte after argument decoding. Standard JSON escaping applies: use `\n` for newline, `\\n` for literal backslash-n. If the file already exists, you must set overwrite=true to replace it."
}
func (t *WriteFileTool) Parameters() map[string]any {
@ -883,7 +883,7 @@ func (t *WriteFileTool) Parameters() map[string]any {
},
"content": map[string]any{
"type": "string",
"description": "Content to write to the file. In `function.arguments`, use \\n for newline and \\\\n for literal backslash-n.",
"description": "Content to write to the file. Standard JSON escaping applies: use `\n` for newline, `\\n` for literal backslash-n.",
},
"overwrite": map[string]any{
"type": "boolean",