Repository navigation
bench: measure context tokens per request over a scripted session - #430
Merged
Merged
Conversation
`scripts/bench_tokens.py` runs a fixed two-turn session (large and small read, grep, a 60-line write, a failing 4,000-line test, then a second turn) against the repository in `--plain` mode. A local OpenAI-compatible mock plays the model and records every request, under a throwaway `WHYCODES_HOME`. For each request it counts the input (tiktoken o200k when installed, chars/4 otherwise) and the prefix repeated byte for byte from the previous request, i.e. what a prompt cache can serve. `--compare` runs a second binary side by side. docs/benchmarks.md records v0.6.33 against v0.6.34: total input 305,828 -> 187,053 (-39%), uncached 152,356 -> 49,536 (-67%), with the source of each saving, and why the one remaining cache miss (shrinking old results in place) is kept: it pays for itself in about a dozen requests with a prompt cache and immediately without one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 7, 2026
Merged
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.
Makes the token measurements behind #418–#428 repeatable, so the savings can be re-checked after any change to prompts, tool output or context handling.
scripts/bench_tokens.py--plainmode against the repository:WHYCODES_HOME, so the real account is never touched and nothing is billed. The test file written during the run is removed afterwards.uncached, the remainder.--compareruns a second binary side by side, and--jsonrecords the result.docs/benchmarks.mdChecks
check_tracked_secretsis ok (the mock keysk-mockis not flagged).🤖 Generated with Claude Code