Skip to content

Command-aware output compression for dev-tool commands - #439

Merged
mohitranka merged 1 commit into
mainfrom
feat/command-aware-output-compression
Aug 26, 2026
Merged

mohitranka merged 1 commit into
mainfrom
feat/command-aware-output-compression

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Summary

  • Adds forge_tools::compress_tool_output — recognizes the command behind bash, exec_command, background_run, and the structured git tool, and applies a conservative, structure-aware filter before the existing size-threshold offload.
  • Test-run collapsing: for cargo test/nextest, pytest, go test, npm/yarn/pnpm test, jest, drops only lines that unambiguously report a passing test, keeping every failure, its surrounding output, and the summary footer verbatim.
  • git diff header stripping: drops the redundant diff --git a/x b/x / index <hash> lines (already duplicated by the --- a/x/+++ b/x lines immediately below), leaves every hunk untouched. Skipped for --stat/--numstat/--name-only, which are already minimal.
  • Both filters are no-ops (return the original body unchanged) when nothing matches, so short or already-compact output is never touched or padded.

Inspired by rtk's approach to CLI output compression, adapted to forge's existing tool-output pipeline rather than as an external proxy — forge already owns every tool implementation, so this applies uniformly across all of them instead of only to shell-hook boundaries.

Test plan

  • cargo fmt --all clean
  • cargo clippy --workspace --all-targets clean
  • cargo test --workspace green (full suite, exit 0)
  • 13 new forge-tools unit tests (command-text extraction across all 4 tool shapes, collapse logic across cargo/pytest/go/jest marker formats, diff filter, no-op cases)
  • 1 new forge-core end-to-end test driving a fake bash tool call through the real begin_model_response_application → finish_tool_application pipeline, asserting the transcript holds the compressed result

https://claude.ai/code/session_01Tb5bxZgFovoKct29q9VEgs

Applies a conservative, structure-aware filter to recognized shell/git
output before the generic size-threshold offload: collapses passing
test lines from cargo/pytest/go test/jest/npm-yarn-pnpm test runs
while keeping every failure and its context verbatim, and strips
git diff's redundant diff/index bookkeeping headers. Both filters are
no-ops when nothing matches, so short or already-compact output is
never touched.

Claude-Session: https://claude.ai/code/session_01Tb5bxZgFovoKct29q9VEgs
@mohitranka
mohitranka merged commit 57ba4de into main Aug 26, 2026
7 checks passed
@mohitranka
mohitranka deleted the feat/command-aware-output-compression branch August 26, 2026 00:41
mohitranka added a commit that referenced this pull request Sep 11, 2026
…439)

Applies a conservative, structure-aware filter to recognized shell/git
output before the generic size-threshold offload: collapses passing
test lines from cargo/pytest/go test/jest/npm-yarn-pnpm test runs
while keeping every failure and its context verbatim, and strips
git diff's redundant diff/index bookkeeping headers. Both filters are
no-ops when nothing matches, so short or already-compact output is
never touched.

Claude-Session: https://claude.ai/code/session_01Tb5bxZgFovoKct29q9VEgs
mohitranka added a commit that referenced this pull request Sep 11, 2026
…439)

Applies a conservative, structure-aware filter to recognized shell/git
output before the generic size-threshold offload: collapses passing
test lines from cargo/pytest/go test/jest/npm-yarn-pnpm test runs
while keeping every failure and its context verbatim, and strips
git diff's redundant diff/index bookkeeping headers. Both filters are
no-ops when nothing matches, so short or already-compact output is
never touched.

Claude-Session: https://claude.ai/code/session_01Tb5bxZgFovoKct29q9VEgs
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