Skip to content

fix(search): bounded, fail-closed search_files fallbacks with shared engine/ordering policy (salvage #97770) - #101714

Merged
kshitijk4poor merged 19 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/97770-search-fallbacks
Sep 2, 2026
Merged

kshitijk4poor merged 19 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/97770-search-fallbacks

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Contributor

Summary

search_files gets a bounded, fail-closed fallback path when rg is unavailable or a probe finds nothing: a shared agent/search_policy.py decides engine + ordering, filename walks are serialised per root, heavy trees are pruned from the zero-match probe, and the Windows/find fallback normalises its paths — so no-rg hosts stop burning CPU on concurrent unbounded walks.

Salvaged from #97770 by @royalaid (all 19 commits cherry-picked, authorship preserved) onto current main; every conflict was import-line merging against #95160/#95940 which landed first.

Who hits this / when / why it matters

Installs without rg (Windows without Git-for-Windows extras, minimal containers) and any host where a filename search walks a large tree: the previous fallbacks ran unbounded find walks concurrently per call and could return partial results silently on error.

What changed (19 commits, on-topic per-commit — search ordering / fallback / interrupt)

  • agent/search_policy.py (new): engine selection + "fast discovery" file ordering, shared by the tool and the code sandbox.
  • tools/file_operations.py: fallback scans unified and fail-closed (partial errors rejected, explicit roots preserved), bounded rg SIGPIPE accepted, root options terminated, dash-prefixed and macOS-glob roots handled, filename walks serialised by root, admission-cancellation race closed.
  • agent/subdirectory_hints.py: heavy trees pruned from the zero-match probe.
  • Tests: test_search_files_engine_selection.py, test_search_files_cpu_windows.py (new) + interrupt-publisher hardening.

Verification

Provenance

Salvaged from #97770 by @royalaid — 19 commits cherry-picked with authorship preserved (noreply email). My only changes are the import-line conflict resolutions inside the cherry-picks.

@kshitijk4poor
kshitijk4poor enabled auto-merge (rebase) September 2, 2026 23:22
@kshitijk4poor
kshitijk4poor merged commit 48a0034 into NousResearch:main Sep 2, 2026
37 checks passed
@alt-glitch alt-glitch added type/perf Performance improvement or optimization P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/file File tools (read, write, patch, search) tool/code-exec execute_code sandbox platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows labels Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows tool/code-exec execute_code sandbox tool/file File tools (read, write, patch, search) type/perf Performance improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants