Skip to content

Commit 2fc02f6

Browse files
bobbyjohnstxclaude
andcommitted
fix: trim whitespace from file paths in read/edit/write tools
Some models (e.g., ornith:9b) append trailing newlines to tool call string arguments. The read tool rejected these with "File not found" because the path included a \n character. Adding .trim() to filePath parameters in read, edit, and write tools fixes this for all models. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f70a1d2 commit 2fc02f6

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎packages/tinycode/src/tool/edit.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ export const EditTool = Tool.define(
7777
}
7878

7979
const instance = yield* InstanceState.context
80-
const filePath = path.isAbsolute(params.filePath)
81-
? params.filePath
82-
: path.join(instance.directory, params.filePath)
80+
const filePath = path.isAbsolute(params.filePath.trim())
81+
? params.filePath.trim()
82+
: path.join(instance.directory, params.filePath.trim())
8383
yield* assertExternalDirectoryEffect(ctx, filePath)
8484

8585
let diff = ""

‎packages/tinycode/src/tool/read.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export const ReadTool = Tool.define(
202202
ctx: Tool.Context,
203203
) {
204204
const instance = yield* InstanceState.context
205-
let filepath = params.filePath
205+
let filepath = params.filePath.trim()
206206
if (!path.isAbsolute(filepath)) {
207207
filepath = path.resolve(instance.directory, filepath)
208208
}

‎packages/tinycode/src/tool/write.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ export const WriteTool = Tool.define(
3838
execute: (params: { content: string; filePath: string }, ctx: Tool.Context) =>
3939
Effect.gen(function* () {
4040
const instance = yield* InstanceState.context
41-
const filepath = path.isAbsolute(params.filePath)
42-
? params.filePath
43-
: path.join(instance.directory, params.filePath)
41+
const filepath = path.isAbsolute(params.filePath.trim())
42+
? params.filePath.trim()
43+
: path.join(instance.directory, params.filePath.trim())
4444
yield* assertExternalDirectoryEffect(ctx, filepath)
4545

4646
const exists = yield* fs.existsSafe(filepath)

0 commit comments

Comments
 (0)