| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Hey! Your PR title Feat/cache audit logging doesn't follow conventional commit format. Please update it to start with one of:
Where scope is the package name (e.g., app, desktop, opencode). See CONTRIBUTING.md for details. |
Sorry, something went wrong.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Sorry, something went wrong.
…NCODE_CACHE_AUDIT Co-authored-by: Bhagirathsinh Vaghela <bhagirathsinh.vaghela.001@gmail.com>
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Sorry, something went wrong.
|
Reopen it, we need to track cache hit obviously |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Issue for this PR
Closes #5416, #5224
Related: #14065, #5422, #14203, #14743
Part of the stacked PR decomposition of the prompt caching fix (1 of 4). Adds cache token audit logging as observability foundation, the metrics logged here are what we use to verify cache hit improvements in subsequent PRs.
Type of change
What does this PR do?
Adds cache token audit logging behind OPENCODE_EXPERIMENTAL_CACHE_AUDIT=1, providing per-LLM-call cache hit/miss visibility. This PR is purely observability — it does not change any caching behavior.
Changes:
packages/core/src/flag/flag.ts — adds OPENCODE_EXPERIMENTAL_CACHE_AUDIT flag.
packages/opencode/src/session/session.ts — adds rawInputTokens to the usage return value (sum of input + cache read + cache write), needed by both the log and sidebar display.
packages/opencode/src/session/processor.ts — after each LLM call's getUsage(), if the flag is set, logs a [CACHE] line with total input tokens, cache read/write/new breakdown, hit percentage, and output tokens.
packages/opencode/src/cli/cmd/tui/feature-plugins/sidebar/context.tsx — when the flag is set, displays a "Cache Audit" box in the TUI sidebar showing the same token breakdown and hit rate in real time.
Why this PR first: The subsequent PRs in the stack improve cache hit rates. This PR provides the measurement tooling to verify those improvements work.
How did you verify your code works?
Set OPENCODE_EXPERIMENTAL_CACHE_AUDIT=1 bun dev, send a prompt, and confirm:
Tests: bun test packages/opencode/test/session/session.test.ts passes.
Screenshots
Checklist
Co-authored-by: Bhagirathsinh Vaghela bhagirathsinh.vaghela.001@gmail.com