feat(apply-fix): tool-augmented Claude can explore + patch any repo - #15
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.