Skip to content

fix(gemini): include tool tokens in reported totals - #531

Merged
junhoyeo merged 3 commits into
mainfrom
fix/gemini-tool-token-totals
May 10, 2026
Merged

fix(gemini): include tool tokens in reported totals#531
junhoyeo merged 3 commits into
mainfrom
fix/gemini-tool-token-totals

Conversation

@junhoyeo

@junhoyeo junhoyeo commented May 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Count Gemini direct tool tokens in the reported token total by carrying them into the input bucket until Tokscale has a dedicated tool-token bucket.
  • Invalidate persisted source-message-cache entries so existing users are reparsed with the updated accounting.
  • Add JSON and JSONL regressions for non-zero tool counts.

Validation

  • rustfmt --edition 2021 --check crates/tokscale-core/src/message_cache.rs crates/tokscale-core/src/sessions/gemini.rs
  • cargo test -p tokscale-core gemini --quiet
  • cargo test -p tokscale-core message_cache --quiet
  • cargo check -p tokscale-core --quiet
  • Old-cache upgrade repro: main/schema12 cached input 10, PR/schema13 reparsed input 17 for a Gemini JSONL row with tool: 7.

Risk

  • Source-message-cache schema bump invalidates persisted parsed-message cache once. Tool tokens are counted as input because Tokscale currently has no dedicated tool-token bucket.

@vercel

vercel Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
tokscale Ignored Ignored Preview May 10, 2026 6:25am

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Invalidate persisted source-message cache entries so existing Gemini files are reparsed with the updated parser behavior instead of reusing stale token/cache-policy results.

Constraint: Source fingerprints only track file contents, not parser-accounting semantics.
Confidence: high
Scope-risk: moderate
Tested: rustfmt --edition 2021 --check crates/tokscale-core/src/message_cache.rs crates/tokscale-core/src/sessions/gemini.rs
Tested: cargo test -p tokscale-core gemini --quiet
Tested: cargo test -p tokscale-core message_cache --quiet
Tested: cargo check -p tokscale-core --quiet
@junhoyeo
junhoyeo force-pushed the fix/gemini-tool-token-totals branch from 3e3860f to 3d347ca Compare May 10, 2026 06:22
@junhoyeo
junhoyeo merged commit 9bb160c into main May 10, 2026
5 checks passed
@junhoyeo
junhoyeo deleted the fix/gemini-tool-token-totals branch May 10, 2026 08:01
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.

1 participant