Skip to content

feat(tools): preserve sampled output for selective rereading - #566

Open
caihongwei2006 wants to merge 2 commits into
scitix:mainfrom
caihongwei2006:codex/tool-output-sampling
Open

caihongwei2006 wants to merge 2 commits into
scitix:mainfrom
caihongwei2006:codex/tool-output-sampling

Conversation

@caihongwei2006

@caihongwei2006 caihongwei2006 commented Sep 7, 2026

Copy link
Copy Markdown

Summary

Long command results currently keep only their head and tail, and later context pruning can erase the saved-output reference. Sample across the full result and retain a task-scoped reference so the agent can inspect omitted lines without rerunning the command.

The preview starts with an 8,000-character budget, distributed across ceil(length / 8000) samples. Each edge keeps at least 2,000 characters through additional allocation; the remaining gaps are evenly spaced. A 36,000-character result therefore returns 2000 + 1600 + 1600 + 1600 + 2000 source characters, with four 6,800-character gaps.

tool_output(output_id, block_id) expands a numbered omitted block into its original inclusive line range; previews include the exact expansion call. The reader also supports selected-line reads and 8k-bounded continuation that stops at the selected block’s final line. Sanitized originals survive idle session rebuilds and are reclaimed on explicit task close; context and persistence guards retain retrieval references. Command/script capability groups include the reader, while legacy explicit whitelists keep the existing file/read fallback. No new production dependencies.

Test Plan

  • Sampling, edge minima, Unicode boundaries, and rendered range labels
  • Block-to-line mapping, block-bounded continuation, selective reads, concurrent task isolation, and sanitized storage
  • Reference preservation across context/persistence pruning and cleanup after task closure
  • Full npm test on the isolated branch based on current main
  • npx tsc --noEmit
  • npm run build
  • Manual live-agent verification

jtang added 2 commits September 7, 2026 19:00
Keep evidence across long command results without filling the model context. Save sanitized originals for task-scoped line retrieval, preserve their references through pruning, and retain at least 2k at each edge outside the 8k base allocation.

Tested: npm test (6790 passed, 2 skipped), npx tsc --noEmit, npm run build

Not-tested: manual live-agent verification
Let the agent select a numbered gap directly instead of calculating offset and line count from the preview. Resolve its inclusive source line range and retain block scope during bounded continuation.

Tested: npm test (6793 passed, 2 skipped), npx tsc --noEmit, npm run build
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.

1 participant