mirror of
https://github.com/langchain-ai/deepagentsjs.git
synced 2026-08-24 22:11:26 -04:00
590c2a5042
## Summary
- Fixes `RangeError: Maximum call stack size exceeded` from
`CompositeBackend.glob`/`grep` when a broad search (e.g.
`**/*.{ts,tsx,...}` at `/`) returns hundreds of thousands of entries.
Root cause: results were merged with `push(...entries)`, which passes
each entry as a separate function argument and overflows V8's
argument-stack limit. Now accumulated with a plain loop.
- Ports the Python SDK's grep match-count cap (`ef591e7`): optional
`maxCount` backend param / `max_count` tool arg, `grepMaxCount`
middleware option (default 1000, `null` disables), `truncated` flag on
`GrepResult`/`GlobResult`, and a truncation note in the grep tool
output. `CompositeBackend` splits the budget across routes and
OR-propagates `truncated`.
## Backward compatibility
- `truncated` is optional; `maxCount` defaults to unset everywhere. No
required changes for existing or new users.
## Test plan
- [x] Regression test: mocked backend returning 200k entries —
`glob`/`grep` complete without `RangeError` (verified it fails with the
old spread).
- [x] Cap enforcement, `truncated` propagation across composite routes,
middleware note rendering.
- [x] `pnpm test` (format + lint + all lib tests) passes.