Repository navigation
fix(ui): bound the Agent UI file search and report truncation - #4354
Conversation
A file search in the Agent UI could walk the whole home directory with no limit, tying up the server for minutes, or forever when one directory read blocked (a cloud mount, a macOS privacy prompt). The walk now stops after 20,000 directory entries or 10 seconds, skips re-walking Documents/Downloads/Desktop/OneDrive during the home pass, and runs on its own daemon thread so a read that never returns can't hold an executor slot. The endpoint stops waiting shortly after the deadline and returns whatever it found. The response gains `truncated`, and the file browser tells the user when a search stopped early. Fixes amd#4352
Approve with suggestionsFile search in the Agent UI could walk an entire home directory without limit, and would never return at all if one directory read blocked. This PR bounds the walk (20,000 entries / ~10s), returns whatever it found, and tells the user when the search stopped early. The fix is well-targeted and the tests are honest — all five new ones fail on One thing worth addressing before merge: every search now starts its own thread with no ceiling on how many can be in flight. On the exact machine this PR is written for — one with a cloud mount that blocks — a stuck search holds its thread long after the request has already answered, so a user mashing Enter, or an agent calling the file-search tool in a loop, can pile threads up indefinitely. The walk deliberately doesn't share the server's thread pool, which is the right call; it just needs a cap on how many walks can run at once (rejecting the extras rather than queueing them, since a queued walk would time out and report "stopped early" with nothing found). Smaller things: the spec doc that describes this endpoint still says file search uses the old pattern and points future authors at it as the example to copy, so it now teaches the wrong thing. And if the walk crashes after the deadline has already passed, the error is dropped and the caller gets a normal "stopped early" answer instead of a failure. Real-world evidenceN/A — no The verdict therefore rests on static review plus what the PR description itself reports. The description's route-level evidence is real and matched to the change: five new integration tests drive the actual The user-visible half is not shown. The "Search stopped early" note is a new Agent UI element and the PR's own manual-check box for it is unchecked, with no screenshot on the PR. A Vitest test covers the note's render logic, which is not the same thing. Please add the before→after screenshot from a large home directory when the strix-halo lane is available — nudge, not a blocker, given the route evidence above. 🔍 Technical details🟡 ImportantUnbounded thread-per-request for the walk (
The comment at 🟢 MinorStale pattern guidance in the spec doc ( Two claims in §3 are no longer true after this change: A post-deadline walk failure is swallowed (
The "Back to browsing" handler clears Existing search tests still walk the real The new file's Strengths
|
# Conflicts: # src/gaia/ui/routers/files.py
amd#4354 added `truncated` to FileSearchResponse after this branch last regenerated, so the committed artifacts were stale and this PR's own drift check failed against them.
Main moved a long way under this branch. Conflict resolutions: - test_unit.yml / test_lane_allowlist.yml: main fixed tests/mcp/test_mcp_cli_to_agent_workflow.py and test_mcp_sdk_integration.py and now runs them in offline-integration, so their allowlist entries are dropped and main's run-list wins. This branch's module_skips section and its in-lane guard step are kept -- they are the point of the PR. - util/lint.py, docs/reference/dev.mdx: main's new --tool-descriptions check kept alongside this branch's module_skips documentation. - tests/integration/test_tui_control_e2e.py: main's CLICOLOR_FORCE fix, which is what this branch's CI run was failing on. - tests/integration/test_memory_integration.py: main's schema bump 4 -> 5. Also closes the two review findings: - tui/** added to both path-filter blocks of test_unit.yml. The offline integration job owns the TUI end-to-end test, but the workflow was not triggered by changes under tui/ -- a TUI-only PR went green without ever running the test that drives the TUI. That is the same "looks green, never ran" shape this PR exists to fix, one level up. - The two no-lane allowlist groups now reference amd#4390 and amd#4391, so the owner decisions they are waiting on are actually tracked. One extra fix the guard itself demanded: tests/integration/test_files_search_budget.py (added by amd#4354) is run by no lane, which fails check_test_lane_coverage.py on main today. This PR makes that check blocking, so the file is wired into offline-integration beside test_files_router.py, which shares its dependencies.
Searching files in the Agent UI could walk the entire home directory with no limit. On a real machine one search took minutes, and it never returned at all if one directory read blocked, for example on a cloud mount or a macOS privacy prompt. Now a search stops after 20,000 entries or about 10 seconds and returns what it found so far. The file browser says so when a search stopped early.
Test plan
python -m pytest tests/integration/test_files_search_budget.py -q: 5 passed. All 5 fail onmain.python -m pytest tests/integration/test_files_search_budget.py tests/integration/test_files_router.py tests/unit/chat/ui/test_models.py -q: 111 passed, 1 skipped. On this Mac,test_files_router.py's search tests hung past 10 minutes against the real home dir before this change; each now returns at the ~11 s cap.cd src/gaia/apps/webui && npx vitest run: 400 passed. The new truncation-note test fails without the component change.cd src/gaia/apps/webui && npx tsc --noEmit: cleangaia eval agent: the Agent UI MCP server'ssearch_filestool result gains atruncatedfield🔍 Technical details
opendir, so the endpoint also stops waiting at budget + 1 s grace. A stuck thread exits once its read returns, and it never holds a shared executor slot.$HOMEpass skips the four priority folders it already walked at greater depth.truncatedis true only when the entry cap or time budget cut the walk short, not whenmax_resultswas reached.api.gen.tsneeds regenerating forFileSearchResponse.truncated. fix(ui): store uploads and managed documents under GAIA_HOME #4348 edits other parts ofrouters/files.py(the upload dir). New tests are in their own file to stay clear of ci(test): run the offline integration suites and make the lane check blocking #4344/fix(ui): store uploads and managed documents under GAIA_HOME #4348's edits totest_files_router.py. The docs edit is outside docs(agent-ui): remove fictional /api/mcp/* routes, document the rest of the API #4340's hunks.Fixes #4352