Skip to content

Resolve model-emitted /<repo>/ paths onto work_dir; locate rg via PATH; Read lists directories#1

Open
dannyg-sys wants to merge 1 commit into
CAMV1234:mainfrom
dannyg-sys:fix/path-resolution-rg-read
Open

Resolve model-emitted /<repo>/ paths onto work_dir; locate rg via PATH; Read lists directories#1
dannyg-sys wants to merge 1 commit into
CAMV1234:mainfrom
dannyg-sys:fix/path-resolution-rg-read

Conversation

@dannyg-sys

@dannyg-sys dannyg-sys commented Jul 13, 2026

Copy link
Copy Markdown

Summary

Three robustness fixes to the file tools so paths and executables the model emits resolve correctly against the working directory, plus a small .gitignore entry.

Changes

1. Resolve model-emitted /<repo>/… paths onto work_dir

New shared helper resolve_path(path, cwd) in tool.py, now used by Read, Grep, and Glob.

The model was trained on SWE-bench instances where repos are mounted at /<repo-name>/, so it frequently emits absolute-looking paths such as /myrepo/src/x.py that don't exist on the local filesystem. resolve_path remaps them onto cwd:

  • relative paths → joined onto cwd;
  • an existing absolute path → returned unchanged;
  • /<repo-name>[/rest]cwd[/rest] (when the first segment matches cwd's basename or the remapped path exists);
  • /src/… style → cwd/src/… when that exists;
  • otherwise the original path is returned untouched (no silent misdirection).

Grep still enforces its existing "within working directory" guard after resolution, so the sandbox boundary is unchanged.

2. Locate ripgrep via PATH (grep.py)

_rg_path was hard-coded to /usr/bin/rg. It now uses shutil.which("rg") and falls back to /usr/bin/rg, so Grep works on macOS/Homebrew and other layouts where rg isn't in /usr/bin.

3. Read on a directory lists its contents (read.py)

Passing a directory path to Read previously errored. It now returns a sorted listing (directories suffixed with /) instead of failing, making directory paths self-correcting for the model.

4. .gitignore

Ignore the .fastcontext/ working directory.


5 files changed, 44 insertions(+), 6 deletions(-).

@dannyg-sys dannyg-sys changed the title fix: resolve model-emitted /<repo>/ paths onto work_dir, locate rg via PATH, Read lists directories Resolve model-emitted /<repo>/ paths onto work_dir; locate rg via PATH; Read lists directories Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant