Skip to content

feat(apply-fix): tool-augmented Claude can explore + patch any repo - #15

Merged
ralyodio merged 1 commit into
masterfrom
feat/apply-fix-agentic-tools
May 22, 2026
Merged

ralyodio merged 1 commit into
masterfrom
feat/apply-fix-agentic-tools

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Replaces single-shot Apply Fix with an agentic loop. Claude gets list_directory / read_file / search_code / write_file / done tools and explores the repo until it stages a fix. Cap: 20 iterations, 200KB total writes, blocklist for vendored paths. Prompt-cached system+tools block. ~$0.10 typical / $0.40 worst-case Claude cost — 1 credit covers it comfortably.

Replaces the single-shot Apply Fix with an agentic loop: Claude has
tools to navigate the repository and stages writes until it's satisfied.
The previous implementation pre-loaded a heuristic set of files (e.g.
"robots.* finding → public/robots.txt") and asked for a one-shot patch;
that failed any time the file lived somewhere we didn't anticipate.

Tools exposed to Claude:

- list_directory(path): list immediate children of a path. Use "" for root.
- read_file(path): read file contents from the default branch. Truncates
  at 50KB to bound token usage.
- search_code(query): GitHub Code Search for a literal substring across
  the repo. Useful for finding components / patterns in monorepos.
- write_file(path, content): STAGE a write. Buffered until done().
- done(summary): signal completion with a PR-body-ready explanation.

Safety / cost limits hardcoded:
- 20 iteration cap.
- 50KB per file read, 100KB per file write, 200KB total writes.
- 100 dir entries per list.
- Blocklist for generated / vendored paths (.git, node_modules, dist,
  build, .next, .cache, coverage, *.lock, pnpm-lock.yaml, etc.).
- Prompt cache on the static system prompt + tools block via
  cache_control: ephemeral — drops typical input cost ~80% per turn.

Cost expectation: ~$0.10 typical, ~$0.40 worst-case (per fix). Still
1 credit; healthy margin at $0.50-$1.00 per credit.

API changes:
- POST /api/projects/[id]/github/apply-fix now also accepts root_path
  as an optional monorepo hint. Threaded to applyFix() which passes
  the hint into the user prompt.
- maxDuration bumped to 300s for the worst-case 20-turn loop.

Existing UI / credit accounting / refund-on-failure unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ralyodio
ralyodio merged commit 545ac03 into master May 22, 2026
@ralyodio
ralyodio deleted the feat/apply-fix-agentic-tools branch May 22, 2026 14:20
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