Skip to content

fix(tools): file search looks in GAIA's own documents folder - #5658

Merged
kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:kalin/search-gaia-documents
Oct 23, 2026
Merged

kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:kalin/search-gaia-documents

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Asked to find and delete a file it had saved itself, GAIA searched the home folder and then the whole drive, and told the user the file doesn't exist. File search skips every folder whose name starts with a dot, so GAIA's own documents folder (~/.gaia/documents, the chat's default read/write folder) was never searched. Now "home" and "everywhere" searches also look in GAIA's documents folder and in any folder the chat was granted that sits under a skipped folder. Other dot-folders such as ~/.cache are still skipped, and nothing outside the requested scope gets added.

How it combines with #5565 and #5554: this only adds folders to the list a search walks. It leaves the walkers alone. The extra folders share #5565's one time and entry budget, and #5554's per-file readability check applies inside them. Both PRs already conflict with current main. This branch adds no new conflict regions to either one (checked with git merge-tree).

Evals: no local run. This changes find_files / search_file results the model sees. Watch gaia_files, gaia_tool_selection and tool_selection on the next RC.

Test plan

  • python -m pytest tests/unit/test_search_gaia_documents.py: 8 passed, and 7 of them fail without the fix
  • Every unit test file that uses find_files or search_file, plus test_file_tools.py: 679 passed, 17 skipped
  • python util/lint.py --black --isort passes
  • In the desktop app, save a file to GAIA's documents folder, then ask GAIA to find it. find_files with scope home returns it.
🔍 Technical details
  • hidden_granted_roots() in search_scope.py returns gaia_home()/"documents" plus the validator's allowed_paths (minus the scratch dir) when a walk of the search roots would skip a folder on the way to them. A candidate is returned only if it sits under one of the roots, so confine_roots, ProtectedFolders and the content search's per-file read check all still apply. Candidates go outermost first, so ~/.gaia and ~/.gaia/documents both granted still return each file once.
  • find_files appends these as extra roots. search_file walks them after its phase-0 roots at SHALLOW_ROOT_DEPTH, and it already dedupes its results.

Asked to find a file GAIA had saved, the agent searched home and then the
whole drive and told the user it didn't exist: every search walker skips
dot-folders, so ~/.gaia/documents was never entered.

find_files (name and content) and search_file now also walk GAIA's
documents folder and any folder the chat was granted when it sits under a
skipped folder inside the requested scope. Other dot-folders stay skipped,
nothing outside the scope is added, and the existing read checks still apply.
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This fixes a real problem: GAIA couldn't find files it had saved itself. Searches skip every folder whose name starts with a dot, and that includes ~/.gaia/documents, so GAIA told users those files didn't exist. Searches across the home folder or the whole drive now also look in that folder, and in any granted folder that sits inside a skipped one. The extra folders come only from inside the requested scope and share the existing time and file-count limit, so the change doesn't let a search reach anything it couldn't reach before. Tests cover both search tools, nested grants, a relocated GAIA home and the case where the documents folder is out of scope.

Nothing blocks merge. One small gap: one of the two search tools doesn't tell the new helper which folders it skips by name. A granted folder under something like build/ or dist/ would still be missed there, though the other tool now finds it.

Real-world evidence

N/A: no evidence bundle was produced for this run. This verdict rests on static review alone. The change alters what file search returns to the model, and the PR's own desktop-app check is still unticked. The author named gaia_files, gaia_tool_selection and tool_selection as the eval categories to watch on the next RC.

🔍 Technical details

🟢 search_file doesn't pass its skip set (src/gaia/agents/tools/file_tools.py:626)
find_files passes mixin._get_default_excludes(), but search_file calls hidden_granted_roots(self, roots) with the default empty set. Its walker also skips _SKIP_DIRS (node_modules, venv, dist, build, site-packages, …) and names starting with $, Windows or Program Files. A grant under one of those folders is still unreachable from search_file, while find_files finds it. To fix it, hoist _SKIP_DIRS out of search_recursive (it's rebuilt on every recursion today anyway) and pass it in:

                    for hidden in search_scope.hidden_granted_roots(
                        self, roots, _SKIP_DIRS
                    ):

(This needs _SKIP_DIRS defined in the enclosing scope. The $/Windows/Program Files prefixes aren't name-set matches, so they would still differ.)

🟢 Hidden roots are walked at full depth in find_files
In find_files, hidden roots get the home/everywhere default depth (10 for names, 8 for content). In search_file they get SHALLOW_ROOT_DEPTH. That's harmless for ~/.gaia/documents, but a broad grant such as all of ~/.gaia would walk hub installs and caches deeply until the shared budget runs out. Not blocking, because the budget bounds it. Consider capping hidden roots at the shallow depth in both tools so they behave the same.

Strengths

  • The candidate filter only returns a folder whose every walked ancestor would have skipped it. That rules out double-walking, and the outermost-first ordering handles nested grants (test_nested_grants_return_each_file_once).
  • The extra roots come from inside already-confined roots, so confine_roots, ProtectedFolders and the per-file read check still apply. test_documents_outside_the_scope_are_not_added pins this.
  • The tests isolate home and GAIA_HOME to temp dirs and check that .cache stays skipped.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 23, 2026
Merged via the queue into amd:main with commit 0cd6616 Oct 23, 2026
32 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/search-gaia-documents branch October 23, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants