Skip to content

fix(agents): bound grep execution and spill oversized tool output - #376

Open
lefoulkrod wants to merge 5 commits into
mainfrom
codex/tool-output-limits
Open

lefoulkrod wants to merge 5 commits into
mainfrom
codex/tool-output-limits

Conversation

@lefoulkrod

@lefoulkrod lefoulkrod commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Large tool results could overwhelm model context, and expensive Python regex searches could block the app. Oversized results now pass through ToolResultCapHook, which saves their full text to a temporary file and publishes a bounded preview and path before persistence.

The existing grep tool keeps its name, parameters, defaults, and Python matching semantics. Its async wrapper runs the matcher in a disposable process, kills and reaps it on timeout or cancellation, and retains partial matches. Search limits are explicit: 10 seconds, 1 MiB collected output, 8 MiB per file, 4,096-character line excerpts, and at most 10,000 matches. Incomplete results include retry guidance; context accepts 0–100 lines. There are no new search tools, dependency-management changes, or migration.

Validation:

  • 2,027 unit and integration tests passed, including real Python worker timeout/cancellation and FakeProvider root/delegated execution with persisted temporary-file pointers.
  • All 23 focused grep unit tests passed, including 30-line context compatibility.
  • 5 container E2E tests passed against the rebuilt application image: oversized grep/read/shell output, reload and follow-up inspection, stuck-regex recovery, and compaction/resume. FakeProvider drives real tool execution.
  • just check and just tool-docs passed.

Fixes #272.

@lefoulkrod lefoulkrod changed the title fix(agents): spill oversized tool output and bound grep execution fix(agents): bound tool output and replace grep with focused search tools Sep 8, 2026
@lefoulkrod
lefoulkrod marked this pull request as ready for review September 9, 2026 00:50
@lefoulkrod lefoulkrod changed the title fix(agents): bound tool output and replace grep with focused search tools fix(agents): bound grep execution and spill oversized tool output Sep 11, 2026
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.

BUG: Oversized grep results can permanently poison conversation context

1 participant