claudetool: minor patch fixes
- docs
- actually use the more lenient parser in aae47584ce87e0f3e6d9c59a26433f515002816a
- tweak tool description
diff --git a/claudetool/patch.go b/claudetool/patch.go
index d0be332..fb04319 100644
--- a/claudetool/patch.go
+++ b/claudetool/patch.go
@@ -26,6 +26,7 @@
type PatchCallback func(input PatchInput, output llm.ToolOut) llm.ToolOut
// PatchTool specifies an llm.Tool for patching files.
+// PatchTools are not concurrency-safe.
type PatchTool struct {
Callback PatchCallback // may be nil
// Pwd is the working directory for resolving relative paths
@@ -38,14 +39,7 @@
Name: PatchName,
Description: strings.TrimSpace(PatchDescription),
InputSchema: llm.MustSchema(PatchInputSchema),
- Run: func(ctx context.Context, m json.RawMessage) llm.ToolOut {
- var input PatchInput
- output := p.patchRun(ctx, m, &input)
- if p.Callback != nil {
- return p.Callback(input, output)
- }
- return output
- },
+ Run: p.Run,
}
}
@@ -55,7 +49,7 @@
File modification tool for precise text edits.
Operations:
-- replace: Substitute text with new content
+- replace: Substitute unique text with new content
- append_eof: Append new text at the end of the file
- prepend_bof: Insert new text at the beginning of the file
- overwrite: Replace the entire file with new content (automatically creates the file)
diff --git a/loop/testdata/agent_loop.httprr b/loop/testdata/agent_loop.httprr
index a0b8568..9985fbe 100644
--- a/loop/testdata/agent_loop.httprr
+++ b/loop/testdata/agent_loop.httprr
@@ -1,9 +1,9 @@
httprr trace v1
-18219 2468
+18226 2450
POST https://api.anthropic.com/v1/messages HTTP/1.1
Host: api.anthropic.com
User-Agent: Go-http-client/1.1
-Content-Length: 18021
+Content-Length: 18028
Anthropic-Version: 2023-06-01
Content-Type: application/json
@@ -75,7 +75,7 @@
},
{
"name": "patch",
- "description": "File modification tool for precise text edits.\n\nOperations:\n- replace: Substitute text with new content\n- append_eof: Append new text at the end of the file\n- prepend_bof: Insert new text at the beginning of the file\n- overwrite: Replace the entire file with new content (automatically creates the file)\n\nUsage notes:\n- All inputs are interpreted literally (no automatic newline or whitespace handling)\n- For replace operations, oldText must appear EXACTLY ONCE in the file",
+ "description": "File modification tool for precise text edits.\n\nOperations:\n- replace: Substitute unique text with new content\n- append_eof: Append new text at the end of the file\n- prepend_bof: Insert new text at the beginning of the file\n- overwrite: Replace the entire file with new content (automatically creates the file)\n\nUsage notes:\n- All inputs are interpreted literally (no automatic newline or whitespace handling)\n- For replace operations, oldText must appear EXACTLY ONCE in the file",
"input_schema": {
"type": "object",
"required": [
@@ -557,24 +557,24 @@
Anthropic-Organization-Id: 3c473a21-7208-450a-a9f8-80aebda45c1b
Anthropic-Ratelimit-Input-Tokens-Limit: 2000000
Anthropic-Ratelimit-Input-Tokens-Remaining: 2000000
-Anthropic-Ratelimit-Input-Tokens-Reset: 2025-07-30T19:14:22Z
+Anthropic-Ratelimit-Input-Tokens-Reset: 2025-07-31T01:39:04Z
Anthropic-Ratelimit-Output-Tokens-Limit: 400000
Anthropic-Ratelimit-Output-Tokens-Remaining: 400000
-Anthropic-Ratelimit-Output-Tokens-Reset: 2025-07-30T19:14:27Z
+Anthropic-Ratelimit-Output-Tokens-Reset: 2025-07-31T01:39:09Z
Anthropic-Ratelimit-Requests-Limit: 4000
Anthropic-Ratelimit-Requests-Remaining: 3999
-Anthropic-Ratelimit-Requests-Reset: 2025-07-30T19:14:21Z
+Anthropic-Ratelimit-Requests-Reset: 2025-07-31T01:39:03Z
Anthropic-Ratelimit-Tokens-Limit: 2400000
Anthropic-Ratelimit-Tokens-Remaining: 2400000
-Anthropic-Ratelimit-Tokens-Reset: 2025-07-30T19:14:22Z
+Anthropic-Ratelimit-Tokens-Reset: 2025-07-31T01:39:04Z
Cf-Cache-Status: DYNAMIC
-Cf-Ray: 96772db40ff5cf27-SJC
+Cf-Ray: 96796139ad9b17f0-SJC
Content-Type: application/json
-Date: Wed, 30 Jul 2025 19:14:27 GMT
-Request-Id: req_011CRdjhnD2HyANxHw5CqnXv
+Date: Thu, 31 Jul 2025 01:39:09 GMT
+Request-Id: req_011CReF3FF82j1DdKxe9UfcT
Server: cloudflare
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Via: 1.1 google
X-Robots-Tag: none
-{"id":"msg_01LPHcYnvczudVFZMnpNPsv2","type":"message","role":"assistant","model":"claude-sonnet-4-20250514","content":[{"type":"text","text":"Here are the tools available to me:\n\n**Code & File Management:**\n- `bash` - Execute shell commands\n- `patch` - Modify files with precise text edits\n- `keyword_search` - Search for files/code with conceptual queries\n\n**Task Management:**\n- `todo_read` - Read current task list\n- `todo_write` - Create/update structured task list\n- `think` - Internal note-taking and planning\n\n**Development Workflow:**\n- `codereview` - Run automated code review\n- `done` - Complete work with verification checklist\n\n**Browser Automation:**\n- `browser_navigate` - Navigate to URLs\n- `browser_click` - Click elements\n- `browser_type` - Type into inputs\n- `browser_wait_for` - Wait for elements\n- `browser_get_text` - Read element text\n- `browser_eval` - Execute JavaScript\n- `browser_scroll_into_view` - Scroll to elements\n- `browser_resize` - Resize browser window\n- `browser_recent_console_logs` - Get console logs\n- `browser_clear_console_logs` - Clear console logs\n- `browser_take_screenshot` - Capture screenshots\n\n**Utilities:**\n- `read_image` - Read and encode image files\n- `about_sketch` - Get help about Sketch itself"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":4177,"cache_read_input_tokens":0,"output_tokens":308,"service_tier":"standard"}}
\ No newline at end of file
+{"id":"msg_01MrEYnet6DtgPztpsmM8fFX","type":"message","role":"assistant","model":"claude-sonnet-4-20250514","content":[{"type":"text","text":"Here are the tools available to me:\n\n**File & Code Management:**\n- `bash` - Execute shell commands\n- `patch` - Modify files with precise text edits\n- `keyword_search` - Search codebase by keywords/concepts\n\n**Task Management:**\n- `todo_read` - Read current task list\n- `todo_write` - Create/update task list\n- `think` - Internal notes and planning\n\n**Development Workflow:**\n- `codereview` - Run automated code review\n- `done` - Mark work complete with checklist verification\n\n**Browser Automation:**\n- `browser_navigate` - Navigate to URLs\n- `browser_click` - Click elements\n- `browser_type` - Type into inputs\n- `browser_wait_for` - Wait for elements\n- `browser_get_text` - Read element text\n- `browser_eval` - Execute JavaScript\n- `browser_scroll_into_view` - Scroll to elements\n- `browser_resize` - Resize browser window\n- `browser_recent_console_logs` - Get console logs\n- `browser_clear_console_logs` - Clear console logs\n- `browser_take_screenshot` - Take screenshots\n\n**Utilities:**\n- `read_image` - Read and encode image files\n- `about_sketch` - Get help with Sketch functionality"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":4178,"cache_read_input_tokens":0,"output_tokens":304,"service_tier":"standard"}}
\ No newline at end of file