Skip to content

fix(stats): net returned bytes in reduction_pct denominator (#1025) - #1042

Open
LHMQ878 wants to merge 1 commit into
mksglu:mainfrom
LHMQ878:fix/1025-reduction-pct
Open

fix(stats): net returned bytes in reduction_pct denominator (#1025)#1042
LHMQ878 wants to merge 1 commit into
mksglu:mainfrom
LHMQ878:fix/1025-reduction-pct

Conversation

@LHMQ878

@LHMQ878 LHMQ878 commented Aug 8, 2026

Copy link
Copy Markdown

Summary

  • Net returned snippet bytes out of keptOut before computing total_processed, reduction_pct, and tokens_saved
  • Prevents double-counting when indexed stdout is partially returned via ctx_batch_execute, ctx_search, or ctx_fetch_and_index
  • Adds regression tests for the persistStats formula

Fixes #1025

Test plan

  • npx vitest run tests/session/stats-reduction-pct.test.ts
  • Verified indexed 10,001-byte stdout + 3,000-byte returned snippet yields total_processed = 10,001 (not 13,001)

Indexed content returned as query snippets was counted in both keptOut
and totalReturned, inflating total_processed and tokens_saved.

Fixes mksglu#1025
@LHMQ878
LHMQ878 force-pushed the fix/1025-reduction-pct branch from fb4eb1c to 0082b95 Compare August 8, 2026 09:18
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]: Returned content bytes double-counted in reduction_pct denominator

1 participant