Skip to content

Avoid too long search results#57

Merged
kmontag merged 9 commits into
kmontag:mainfrom
yantar92:main
May 6, 2026
Merged

Avoid too long search results#57
kmontag merged 9 commits into
kmontag:mainfrom
yantar92:main

Conversation

@yantar92
Copy link
Copy Markdown
Contributor

  • macher.el (macher--tool-search-helper): Respect `macher--max-read-length' when returning search results.

yantar92 and others added 9 commits April 18, 2026 14:39
* macher.el (macher--tool-search-helper): Respect
`macher--max-read-length' when returning search results.
Rename to `macher-max-tool-output-length' and convert from defconst to
defcustom.  The cap was already being applied by the read tool; making
it customizable lets users tune the limit for their model's context
window, and reusing it for other text-returning tools (in a follow-up)
needs a name that isn't tied to the read tool.

Change-Id: I3f799bd094f15df69bbcc772f722d60c4f7afde0
Apply `macher-max-tool-output-length' to the search and list-directory
tools, which previously could dump unbounded amounts of text into the
LLM context.  Factor the check into `macher--check-output-length' and
reuse it in the read tool for consistency.  When the limit is exceeded,
include the leading and trailing 256 bytes of the output in the error
so the caller can see the structure of the truncated payload.

Change-Id: I0eca3de190b510e00957eeeb47034ec6c1e91d79
Exercise the under-limit/at-limit no-op path, the over-limit error,
the contents of the error message (description, sizes, head/tail
previews), and the small-payload preview-shrinking branch.

Change-Id: I6bab46f6d4d307f54592dac246525d8d4ce7109b
Exercise the under-limit/at-limit no-op path, the over-limit error,
the contents of the error message (description, sizes, head/tail
previews), and the small-payload preview-shrinking branch.

Change-Id: I6bab46f6d4d307f54592dac246525d8d4ce7109b
Brings in the directory workspace type (kmontag#48), no-workspace user-error
fix (kmontag#48), and the large/remote workspace perf fixes (kmontag#60).

Resolved conflicts:
- macher.el (macher--tool-read-file): kept main's perf-improved body
  that skips the redundant path resolution in macher--with-workspace-file,
  but used the new `macher--check-output-length' helper from this branch
  in place of main's inline length check.
- tests/test-unit.el (macher--tool-search-helper): kept both `it'
  blocks added at the same spot (one from each side).

Change-Id: I713522bc98a021f55cf186806c2f34de3d5592a3
@kmontag kmontag merged commit 55e75f2 into kmontag:main May 6, 2026
4 checks passed
@kmontag
Copy link
Copy Markdown
Owner

kmontag commented May 6, 2026

thanks @yantar92!

made a proper defcustom for this and applied the check to the list_directory tool as well, and added a bit more detailed error output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants