Skip to content

fix(platform): price Opus input the same in scan limits and estimates - #986

Open
hyfdev wants to merge 2 commits into
mainfrom
fix/security-opus-early-stop
Open

hyfdev wants to merge 2 commits into
mainfrom
fix/security-opus-early-stop

Conversation

@hyfdev

@hyfdev hyfdev commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

With the default settings, a call in an Opus security scan can be refused much earlier than before #978.

Since #978, each call's estimate prices Opus input at 2× (the price of 1-hour cache writes), but the default spend limit prices it at 1×.

Both now use 1.25×, the price of 5-minute cache writes. In a mocked run, the scanner's Claude SDK asked only for those.

Input tokens a scan has used when an Opus call of this size is first refused (default settings, totals set by the test in steps of 4 tokens, mocked replies, used input billed at 1.25×, no output used; 0 means even with no tokens used) Before #978 main This PR
0.06 MB 1,200,000 921,544 1,175,968
0.5 MB 1,200,000 639,944 999,968
1 MB 1,200,000 319,944 799,968
1.6 MB 1,200,000 0 559,968
2.88 MB 1,200,000 0 47,968
Opus with the default settings (mocked replies, unless noted) Before #978 main This PR
How many of six calls sent at once are allowed before the scan has used any tokens, at 0.06, 0.25, 0.5, 1, 1.6 and 2.88 MB each, in that order 6 each 2, 2, 1, 1, 0, 0 3, 2, 2, 1, 1, 1
Largest call Void allows before the scan has used any tokens (worked out, not run) 16.8 MB, the request limit 1.5 MB 3 MB
Reserved for each scan in the monthly caps, if any are set (a scan needs this much left to start) $7.20 $7.20 $8.40
estimate = (bytes ÷ 2.5) × input price × 1.25 + the call's output token limit × output price
           1.6 MB call (1,600,089 bytes) before the scan has used any tokens:
           640,036 × $4/M × 1.25 + 120,000 × $20/M = $5.60 (on main, × 2: $7.52)

limit    = min(maxInputTokens, 1,200,000) × input price × 1.25 + maxOutputTokens × output price
           default settings:
           1,200,000 × $4/M × 1.25 + 120,000 × $20/M = $8.40 (on main, × 1: $7.20)

The Claude SDK asks for 128,000 output tokens per call. Void lowers that to what's left
of maxOutputTokens (120,000 with none used).

Other models don't change from main, and the monthly caps still hold an Opus call's worst case at 2×.

#978's check before each call stays, so large or concurrent calls can still be refused earlier than before #978.

In four mocked one-session runs, the Claude SDK's main conversation never had two calls running at once, but that doesn't prove it can't. No real install was tried.

Opus estimates are lower than on main, with or without an explicit maxScanUsd, so a call that costs more than its estimate can take a scan further past its limit.

Fixes #985.

@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Cloudflare builds and deploys previews for this pull request. Learn more about Cloudflare previews.

Worker Status Deployment Commit
Not available Deployed Preview dbbeb69

Updated: Dec 1, 2026, 15:02 UTC | Dashboard

@hyfdev
hyfdev marked this pull request as ready for review November 30, 2026 12:07
@hyfdev
hyfdev requested review from Brooooooklyn and a balanced review from Copilot November 30, 2026 12:07

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.

@Brooooooklyn
Brooooooklyn force-pushed the fix/security-opus-early-stop branch from 7c517a1 to dbbeb69 Compare December 1, 2026 15:00

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.

Calls in Opus security scans can be refused too early

3 participants