Skip to content

Add more tools (based on searchfox-py) to the LLM review agent, and make it patch stack aware to a certain extent#6051

Open
padenot wants to merge 2 commits into
mozilla:masterfrom
padenot:searchfox-more-tools
Open

Add more tools (based on searchfox-py) to the LLM review agent, and make it patch stack aware to a certain extent#6051
padenot wants to merge 2 commits into
mozilla:masterfrom
padenot:searchfox-more-tools

Conversation

@padenot
Copy link
Copy Markdown
Collaborator

@padenot padenot commented May 25, 2026

The two patches can be reviewed independently but are close in location so I'm putting one branch for both.

expand_context now shows the file as it appears after the full patch stack
is applied. A new patch_apply module provides reusable primitives:

- strip_diff_prefix, find_patched_file, apply_patched_file: diff utilities
- fetch_with_revision_fallback: try a specific revision, fall back to tip
- get_file_after_stack(patch, path, fetch): applies patch.patch_stack in
  order on top of whatever base the caller provides via fetch()

expand_context calls get_file_after_stack with patch.get_old_file as the
fetch function. The Patch base class gains patch_stack (default: [patch_set])
and get_base_revision(); phabricator.py overrides both. Non-linear stacks
fall back to the current patch only.

expand_context also gains optional start_line / end_line — omitting either
returns from the beginning or to the end of the file.
@padenot padenot force-pushed the searchfox-more-tools branch from 02c806e to 33dbdae Compare May 25, 2026 16:06
Expose the searchfox Python API (searchfox-cli) as LangChain tools wired
into the code review agent. expand_context switches its fetch function
from patch.get_old_file to searchfox at the patch's base revision, using
fetch_with_revision_fallback and get_file_after_stack from patch_apply.

- expand_context: searchfox at base revision + full patch stack applied
- search_text: free-text / regex search with file-type and path filters
- get_blame: per-line commit history
- get_field_layout: C++ class/struct memory layout
- find_definition: look up a function, method, class, or struct
- search_identifier: exact identifier search with file-type filters
- calls_from / calls_to / calls_between: call graph traversal with depth
- check_can_gc: SpiderMonkey GC hazard analysis for C++ functions

All tools support langs (list) and tests filters where applicable.

No additional tests for the tool wrappers: the tools are thin call-and-format
wrappers over searchfox-py, which is tested independently in its own repo.

Closes mozilla#5284
@padenot padenot force-pushed the searchfox-more-tools branch from 33dbdae to 798947f Compare May 25, 2026 16:12
@padenot padenot requested a review from suhaibmujahid May 25, 2026 16:14
@padenot
Copy link
Copy Markdown
Collaborator Author

padenot commented May 25, 2026

padenot/searchfox-cli@v0.10.12...v0.13.0 are the changes in searchfox-py for this (API tightening, adding async, etc.).

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