Skip to content

fix(platform): count cached input at its cached price in security scan limits - #978

Open
hyfdev wants to merge 1 commit into
mainfrom
fix/security-cached-input-cap
Open

hyfdev wants to merge 1 commit into
mainfrom
fix/security-cached-input-cap

Conversation

@hyfdev

@hyfdev hyfdev commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

A full security scan with the default model and limits can stop as incomplete (token_cap) long before it reaches the $0.50 that Void says it can cost.

Cached input now counts toward the scan's input token limit at its cached price instead of in full.

Both scans in #966 stopped at that limit:

maxInputTokens Cost Input cost Counted before Counted now ≈ input cost ÷ $0.30 × 1M
1,200,000 (default) $0.0376 $0.0324 1,279,208 108,000
2,000,000 (maximum) $0.0571 $0.0488 2,034,125 163,000
counted per call = uncached + cached × cached price / full price, rounded up

100,000 input tokens, 95,000 of them cached (100,000 before), prices in $ per 1M tokens:
  default model   5,000 + 95,000 × 0.006 / 0.30 =   6,900
  GLM 5.3         5,000 + 95,000 × 0.26  / 1.40 =  22,643
  other models    100,000 (Void lists no cached price)

Scans with a lot of cached input can now run longer and cost more, as in these four calls on the default model and limits, with mocked replies:

Call Input tokens Cached Before: already counted Now: already counted
1 600,000 0 0, allowed 0, allowed
2 600,000 600,000 600,000, allowed 600,000, allowed
3 587,999 0 1,200,000, refused (429) 612,000, allowed
4 1,048,000 0 1,200,000, refused (429) 1,199,999, allowed
Total cost $0.18 $0.67

As before, the limit is only checked before each call, so the last one can take a scan past $0.50.

With the default model's 1,048,576-token context, the most a scan's model calls can cost is still this, if they run one at a time and report their usage:

limits (shown as $0.50)        1,200,000 × $0.30 / 1M + 120,000 × $1.20 / 1M = $0.504
last call filling the context  1,048,576 × $0.30 / 1M                        = $0.315
total                                                                        = $0.819

tokensIn in the operator API still shows every token, so it can now go well past maxInputTokens.

1.12.0 to 1.12.2 ignore the new security_scans column, so they're listed as safe to upgrade from or roll back to.

Part of #966.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-security-cached-input-cap-void-cloud.voidzero-docs.workers.dev (commit 889b8bb)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://c9e0e08d-void-cloud.voidzero-docs.workers.dev 889b8bb 2026-11-29T04:32:46.496Z Visit the dashboard ↗

@hyfdev
hyfdev marked this pull request as ready for review November 29, 2026 04:36
Copilot AI balanced review requested due to automatic review settings November 29, 2026 04:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@hyfdev
hyfdev requested a review from Brooooooklyn November 29, 2026 05:34
@cpojer

cpojer commented Nov 29, 2026

Copy link
Copy Markdown
Member

imho we should keep maxInputTokens as a token count and give scans a separate spend limit that accounts for the cache discount. Also can we add a check for whether it can afford the next call?

This branch has not been deployed

No deployments
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.

3 participants