fix(file tools): resolve relative paths against WorkDir before workspace validation

When the agent supplies a relative path (e.g. "app.py"), filepath.Abs resolves
it against the process CWD, not the workspace — causing ValidatePathInWorkDir
to reject paths that are legitimately inside the workspace.

Join relative paths with WorkDir before resolution so the agent can use bare
filenames without hitting the outside-workspace error.
This commit is contained in:
sausheong committed 2026-05-12 17:10:32 +08:00
1 parent c2af8f389d
commit 65021e1fe2
3 files changed
+11

No files matched your search

+3
View File
@@ -82,6 +82,9 @@ func (t *ReadFileTool) Execute(_ context.Context, input json.RawMessage) (tool.T
}
in.Path = tool.ExpandHome(in.Path)
if t.WorkDir != "" && !filepath.IsAbs(in.Path) {
in.Path = filepath.Join(t.WorkDir, in.Path)
}
in.Path = tool.ResolveExistingPath(in.Path)
if t.WorkDir != "" {