-
Notifications
You must be signed in to change notification settings - Fork 1
Token Budgets And Reports
karurikwao edited this page Jul 5, 2026
·
1 revision
ContextClean includes exact token counting for OpenAI-compatible o200k_base counts and budget-aware output packing.
Use --max-tokens when you know the target size:
ctxclean build.log --max-tokens 8000Use --fit when you want a model preset:
ctxclean repo . --fit gpt-4.1
ctxclean repo . --fit claude-sonnet
ctxclean repo . --fit gemini-proWhen output must be shortened, ContextClean tries to truncate at readable boundaries:
- paragraphs
- lines
- code block boundaries
- section boundaries where possible
The output includes an explanation footer when truncation is applied.
Example:
[Context Truncated: Removed 14203 tokens to fit 8000-token budget]
Reports explain why a context payload is noisy.
ctxclean report build.log --max-tokens 8000
ctxclean report ./project --format jsonReport output includes:
- input tokens
- output tokens
- tokens saved
- compression ratio
- biggest noise sources
- recommended command
- removed section summary
- warnings
Use --format json for dashboards, CI jobs, or tests.
Useful fields include:
metrics.input_tokensmetrics.output_tokensmetrics.tokens_savedmetrics.compression_ratiometrics.reduction_percentbudgettruncationremoved_sectionsnoise_sourceswarnings
- Use
reportbefore changing cleaning mode. - Use
jsonwhen building automated checks. - Keep benchmark claims tied to measured fixture output.
- Do not promise token savings from unmeasured data.