Skip to content

fix(tools): find a file named with an extension outside the allowlist - #5754

Merged
kovtcharov-amd merged 3 commits into
amd:mainfrom
xubenqiang:fix/search-file-named-extension-3941
Oct 26, 2026
Merged

kovtcharov-amd merged 3 commits into
amd:mainfrom
xubenqiang:fix/search-file-named-extension-3941

Conversation

@xubenqiang

Copy link
Copy Markdown
Contributor

search_file reported an empty directory when the caller named a file whose extension was not on its hard-coded allowlist, so the agent stopped and asked for a location it had already been given. The extension written into the pattern now outranks that list, and the list itself covers logs and configs.

What changed

  • An extension written into the pattern is added to the allowlist before the walk, so ci.log and *.log both work. A regex is not read that way (employ.*book is a pattern, not a .book file), and an explicit file_types still wins over the pattern.
  • The default allowlist gains the formats agent work actually reads: .log, .toml, .yaml, .yml, .ini, .cfg, .xml, .sql, .html, .css, .tsx, .jsx.
🔍 Technical details

Both edits are in FileSearchToolsMixin.register_file_search_tools.<locals>.search_file, src/gaia/agents/tools/file_tools.py. The filter that dropped the files is type_match = file_path.suffix.lower() in doc_extensions, which runs for every candidate, so no pattern could bring in an extension the set did not hold.

The other extension sets the issue's confirmation comment mentions (text_extensions, around lines 1227 and 2181) belong to a different stage — reading file content, not searching by name — and are left alone to keep this change on the reported path.

Test plan

  • pytest tests/unit/test_file_search_scope.py — 47 passed, 6 failed. The 6 are the HOME-walking classes (TestFullAccessSearchesTheWorkspace, TestAHomeSandboxIsCappedToo), and they fail identically on the base commit on this Windows machine; CI runs them on Linux.
  • With the source patch reverted and the new tests kept, 3 of the 5 new tests fail (ci.log by name, *.yml, pyproject.toml) and 2 pass — the tests prove the fix rather than describing it.
  • pytest tests/unit/test_file_tools.py (147 passed, 3 skipped), tests/unit/test_search_file_content_scope.py (8 passed), tests/unit/test_search_gaia_documents.py (8 passed).
  • black --check and isort --check-only clean; flake8 --select=E9,F63,F7,F82 clean.
  • Not run here: the rest of the unit suite (too slow on this machine) and a live agent run of the issue's end-to-end report (needs Lemonade and a model).

Closes #3941

`search_file` filtered every candidate against a hard-coded extension set, so a
caller that named a `.log`, `.toml` or `.yml` file exactly got "nothing found"
and the agent told the user the directory was empty. Two changes: an extension
written into the pattern now outranks the default allowlist, and the allowlist
covers what agent work reads -- logs, configs and web assets, not only documents
and source files.

Refs amd#3941
Copilot AI balanced review requested due to automatic review settings October 25, 2026 06:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions github-actions Bot added tests Test changes agents labels Oct 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This fixes the file-search tool so it finds a file you name exactly, like ci.log, *.yml or pyproject.toml. Before, the tool reported an empty folder when the extension wasn't on a fixed list. It also adds logs and config formats to that default list. The fix is small and narrow, and tests cover it. Nothing blocks the merge.

Two things to consider before merging, neither blocking:

  • Broad searches may get noisier. A search returns at most 20 files, taking whatever it reaches first. The default list now includes web-source types (.html, .css, .tsx, .jsx, .xml), so a loose query like "report" run in a front-end repo can fill those 20 slots with code files and push out the document the user wanted. If that's a real risk, the logs/configs you need (.log, .toml, .yaml, .yml, .ini, .cfg) could go in without the web types. Exact-name lookups already work without them because of the new pattern rule.
  • One new path has no test. The rule that skips patterns written as regular expressions has no test of its own. One case would protect it.

This changes what the agent sees from a tool, so watch the rag_quality / file-search eval categories on the next RC.

Real-world evidence

N/A — no evidence bundle ran for this PR, and the change is an agent tool that needs a live model to exercise end to end (deferred to the strix-halo lane). This verdict rests on reading the code alone. I couldn't run pytest on this runner. The PR description reports the new tests passing and failing correctly when the fix is reverted.

🔍 Technical details

Issues

🟢 Wider default allowlist + first-20 cap can crowd out documents (src/gaia/agents/tools/file_tools.py:471-485)
search_recursive stops at len(matching_files) >= 20, taking files in walk order with no ranking. With no file_types given, a substring query now also matches .html/.css/.tsx/.jsx/.xml. In web projects those can take every slot before the walk reaches the .pdf/.docx the user meant. The pattern-named-extension rule at :494-502 already covers exact lookups like index.tsx or *.html, so the web types don't have to be in the default list. Consider keeping only the log/config additions.

🟢 The regex-exclusion branch has no test (file_tools.py:498-501)
The check that skips patterns with regex metacharacters (+[](){}^$|\) has no test. Every new test uses a plain name or a glob. A case like search_file(r"^ci\.log$") or search_file("(ci|build).log"), with .log dropped from the defaults or an uncommon extension used instead, would pin down that the rule's own guard works. A side note: the code comment's employ.*book example never reaches this guard, because \.ext$ needs a literal . right before the tail and that pattern has * there. The comment is accurate but describes a case the anchor regex already rules out.

🟢 Dotted plain names add junk extensions (harmless)
Queries like John.Smith or report.v2 add .smith / .v2 to the set. No real file has those suffixes, so nothing matches wrongly. Noting it only so it's a known choice.

Strengths

  • An explicit file_types still overrides the pattern, and a test locks that in, so callers who restrict by type are unaffected.
  • The fix sits on the filter that actually dropped the files (type_match) and leaves the content-reading extension sets alone, which keeps the blast radius small.
  • The tests are written as behavior statements and were checked to fail against the unpatched source.

The guard that keeps a regex tail like `(ci|build).xyz` from widening the
allowlist had no test, and the comment above it used an example the anchor
already rules out. The new case uses an extension no other test in the module
touches, so only the pattern rule can find the file.

Refs amd#3941
@xubenqiang

Copy link
Copy Markdown
Contributor Author

Added the missing guard test and corrected the comment: (ci|build).xyz does reach the guard, employ.*book never did — the anchor needs a literal dot right before the tail. The guard case uses .xyz, an extension no other test in the module touches, so only the pattern rule can find the file; it passes on the unpatched source too, which is the point — it pins that the rule does NOT widen the list.

On the default allowlist I kept the five web-source types, because #3941 names them (".sql, .html, .css, .tsx, .jsx"), and the pattern rule finds them by name anyway. Your crowding point is real for a loose substring query in a front-end repo: if you would rather the default stay documents, logs and configs, say so and I will drop those five and keep .log .toml .yaml .yml .ini .cfg .sql.

John.Smith adding .smith is a known, harmless consequence of the same rule.

@xubenqiang

xubenqiang commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

One more regression sweep over the files that exercise search_file, now that the widening is in:

  • tests/unit/test_file_search_accents_and_budget.py → 43 passed.
  • test_tool_recall.py, test_tool_admission_order.py, test_allowed_paths_env.py, test_file_tools_allowed_folders.py, agents/test_file_tools_text_encoding.py, test_search_skips_macos_protected_folders.py together → 197 passed, 21 skipped, 2 failed; the two failures are this Windows box, not the change: WinError 1314 on a symlink and a host-bind test, and both fail identically on main.
  • Earlier: test_file_search_scope.py 49 passed (6 HOME-walking failures, also on main), test_file_tools.py 147 passed / 3 skipped, test_search_file_content_scope.py 8 passed, test_search_gaia_documents.py 8 passed.

Nothing outside that set asserts on the default extension list (git grep doc_extensions -- tests is empty), so no other test needed changing with it.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 26, 2026
Merged via the queue into amd:main with commit ebff3c5 Oct 26, 2026
32 checks passed
@kovtcharov-amd kovtcharov-amd mentioned this pull request Oct 26, 2026
5 of 9 tasks
grtninja pushed a commit to grtninja/gaia that referenced this pull request Oct 26, 2026
## Why this matters

v0.25.2 is a bug-fix release on top of v0.25.1: setup and install no
longer stop at the first failed step, shell and file access handle
Windows paths and text encodings, the Agent UI and desktop app stop
showing misleading states, and document search, email and skills each
lose a handful of rough edges. 55 commits since v0.25.1; notes are in
`docs/releases/v0.25.2.mdx` and credit 15 outside contributors.

## Test plan

- [x] `python util/validate_release_notes.py docs/releases/v0.25.2.mdx
--tag v0.25.2` passes
- [x] `mintlify validate` (from `docs/`) passes
- [x] `python util/check_doc_links.py --internal-only`, `python
util/check_doc_versions.py` and `node
installer/version/bump-ui-version.mjs --check` pass
- [x] `python util/check_component_core_api.py --release-version 0.25.2`
passes
- [x] `pytest tests/unit/test_docs_json_release.py
tests/unit/test_check_component_core_api.py
tests/unit/test_release_tag.py
tests/unit/test_hub_core_version_gate.py`: 156 passed
- [ ] CI green on the merge commit
- [ ] `release_train_dryrun.yml` passes on that commit before the RC tag

## Evals to re-run on the RC tag

LLM-affecting PRs merged without per-PR evals; run these on
`v0.25.2-rc1`:

- `gaia_shell` and shell/safety (amd#5794, amd#5751, amd#5768)
- `gaia_honesty` (amd#5753)
- `gaia_skills_tasks` and `gaia_skills_lifecycle` (amd#5422, amd#5755)
- `rag_retrieval` and `rag_quality` (amd#5742, amd#5754, amd#5761, amd#5817, amd#5812)
- email scenarios (amd#5767, amd#5811)
- `tool_selection` and `error_recovery` (amd#5732)
- Claude provider thinking replay (amd#5072)
- memory categories (amd#5818 merged; amd#5756 has not)

## Release checklist

- [ ] Freeze main, wait for green CI on the exact commit, pass
`release_train_dryrun.yml`, then push `v0.25.2-rc1`
- [ ] Extend the changelog if main gains commits before the tag
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.

fix(tools): search_file can't find a file you name exactly if its extension isn't on the allowlist

3 participants