feat(optimize): detect context-heavy sessions#242
Closed
ozymandiashh wants to merge 1 commit into
Closed
Conversation
Member
|
Superseded by #246, which carries your original commit forward and applies three review fixes on top: Found via real-data probe (22.6K sessions / $4.8K spend):
Plus 7 new tests covering medium/high boundaries, 1000+:1 cap with non-zero output, time-gap suppression, below-threshold anchor growth, and outlier-exclusion behavior. Closing in favor of #246. The cache-aware effective-token approach was the right call — well-built detector, just needed the dedup with outliers and the time-gap polish to match real-world data shape. |
iamtoruk
added a commit
that referenced
this pull request
May 6, 2026
Adds a context-bloat finding to codeburn optimize that flags sessions where effective input/cache tokens (cache-discounted via existing pricing constants) are large and disproportionate to output. Suggests starting fresh with a tightened context. Sessions flagged here are excluded from the cost-outlier finding to avoid double-listing. Growth-from-previous-session callouts are suppressed when the predecessor is more than 7 days back. Three impact tiers (low/medium/high). Supersedes #242 with review fixes from real-data probe. Original implementation by @ozymandiashh.
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
This adds a Context Bloat Analyzer finding to
codeburn optimizeso users can spot sessions where the effective input/cache footprint is much larger than the useful output. The goal is to make it obvious when a fresh thread or tighter context handoff would likely be cheaper than carrying everything forward.detectContextBloat()detector in the optimize pipeline1000+:1so zero-output sessions do not produce noisy numbersDetection model
The detector is intentionally conservative:
This keeps raw cache-read-heavy sessions from being overstated while still catching sessions that are expensive in practice.
Validation
npx vitest run tests/optimize.test.tsnpm run buildnpx vitest runnode dist/cli.js optimize --helpgit diff --checknpx tsc --noEmitstill fails on the existing Copilot provider type errors insrc/providers/copilot.ts, outside this diff. The same failure is present onorigin/main.thats all i got for the moment :)