feat: short-output auto-passthrough — skip compression when raw output is already minimal#2674
Open
lg320531124 wants to merge 1 commit into
Open
Conversation
Author
|
Friendly nudge — open ~28h, CI green. This is a perf win for the common case: when raw model output is already minimal (short responses), skipping compression avoids unnecessary token/latency overhead with no behavior change for longer outputs. +591 all new code + tests, no changes to existing paths. Happy to split into smaller commits or add benchmarks if that eases review. |
When command output is already minimal (≤5 lines, ≤500 bytes), skip the compression pipeline entirely and emit raw output unchanged. This prevents filter reshaping of short signal commands (git push, echo $?, hostname, etc.) and avoids zero-savings compression overhead. - Add PassthroughConfig with short_line_threshold / short_byte_threshold - Add should_auto_passthrough() heuristic in runner.rs - Integrate check in run_captured_filter() after capture, before filter - Track auto-passthrough via track_passthrough() (honest 0% savings) - Config defaults: 0/0 → effective 5/500 (auto-passthrough ON) - Opt-out: set both thresholds to 1 - Complements PR rtk-ai#2667 (hook-level passthrough) at CLI execution layer Files changed: - src/core/config.rs: PassthroughConfig struct, effective_*() methods, tests - src/core/runner.rs: should_auto_passthrough(), integration, tests - docs/contributing/DESIGN-short-output-passthrough.md: full design doc
026b879 to
e8a29f1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2673
When command output is already minimal (≤5 lines, ≤500 bytes), skip the compression pipeline entirely and emit raw output unchanged. This prevents filter reshaping of short signal commands and avoids zero-savings compression overhead.
Problem
RTK compresses all command output. When output is already short, compression:
git pushoutput,echo $?)PR #2667 adds hook-level passthrough for predefined signal commands, but:
rtk git statuscalled directly still compressesecho $?,which python3,hostnameetc. are not in the listgit status -uall(1000 lines) gets the same passthrough as cleangit status(3 lines)Solution
An output-length heuristic at the CLI execution layer that auto-passthroughs any short output, regardless of command name.
Both conditions must be met (AND logic):
line_count ≤ 5— coversgit push(2 lines),echo $?(1 line), cleangit status(3 lines)output.len() ≤ 500— prevents passthrough for very long single-line output (e.g. minified JSON)Interaction with #2667
git push(2 lines)rtk git status(3 lines)rtk git status -uall(1000 lines)echo $?(1 line)rtk git log -50(200 lines)Changes
src/core/config.rsPassthroughConfigstruct,effective_*()methods, config testssrc/core/runner.rsshould_auto_passthrough(), integration inrun_captured_filter(), testsdocs/contributing/DESIGN-short-output-passthrough.mdTotal: ~90 lines of production code (excluding design doc and tests). No new files, no new modules, no new dependencies.
Config
short_line_threshold = 1+short_byte_threshold = 1Test Plan
should_auto_passthrough()(8 test cases)cargo fmt --all && cargo clippy --all-targets && cargo test --all— all pass (2299 tests)rtk git status(short → passthrough) vsrtk git log -50(long → compressed)hyperfinecomparison (passthrough should be faster for short commands)Design Document
Full design doc:
docs/contributing/DESIGN-short-output-passthrough.mdCovers: architecture, insertion point rationale, feature interaction matrix, edge cases, migration strategy, open questions.