You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prefix Budget Hints for Long-Context SDK Dispatch (August 2026)
#72
One SDK surface I keep wanting for long-context agent work is a small, boring prefix budget hint before the request is dispatched.
The problem is not just that context windows are getting bigger. It is that bigger windows make the cost boundary less visible to the application. A coding agent may attach a repository map, tool schemas, issue history, a policy document, and several failed patch attempts. Some of that input is stable enough to cache or hash. Some of it is fresh task text. Some of it is accidental baggage. If the SDK only returns token usage after the model call, the team learns about the shape of the request after it has already paid for the shape of the request.
I checked the live AIWave pricing feed before writing this. /api/pricing returned success=true, pricing version a42d372ccf0b5dd13ecf71203521f9d2, and group ratios of default=3 and vip=1. The current DeepSeek rows exposed through AIWave include:
I also rechecked the official DeepSeek pricing page during this run. It currently lists deepseek-v4-flash and deepseek-v4-pro with 1M context, 384K maximum output, separate cache-hit/cache-miss/output prices, and peak/off-peak windows. The visible USD table has Flash at $0.007/$0.014 cache-hit input, $0.22/$0.44 cache-miss input, and $0.66/$1.32 output per 1M tokens for off-peak/peak. Pro is higher: $0.022/$0.044, $0.66/$1.32, and $1.98/$3.96 on the same buckets.
That makes prefix visibility a first-class SDK concern. A request with 700K cached repository tokens and 20K fresh task tokens is operationally different from a request with 720K uncached input, even if the model ID is identical. It is also different from a request that reserves too little output space and fails near the end of a tool-heavy plan.
The hint I have in mind is not an invoice. It is a pre-dispatch receipt:
This would let the application decide whether to continue, split the job, refresh the prefix cache, downgrade the execution model, or ask a human to approve the request. It would also give support and finance a shared artifact when a customer asks why one agent run cost more than another.
QwenCloud's current pricing docs are another reason to do this outside a single-provider mental model. They describe per-million-token text billing, context-tiered request billing for some models, cache discounts, Batch API discounts, and thinking tokens billed as output. Z.AI's GLM pricing page has its own cached-input and output columns. A useful SDK abstraction should not hard-code one vendor's price table; it should expose the request shape, source timestamp, cache assumption, and selected billing group so the gateway can attach the current rates.
For aiwave-sdk-python, I wonder if this belongs as an optional helper before client.chat.completions.create, something like:
The return value could be logged, used as a guardrail, or passed into the actual call as metadata. It should be easy to disable for small requests, but easy to require for background agents and batch jobs.
Discussion question: should long-context SDKs expose prefix budget hints before dispatch, or should this stay entirely inside gateway logs? I lean toward exposing it, because the application is usually where the bad prompt shape is created.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
One SDK surface I keep wanting for long-context agent work is a small, boring prefix budget hint before the request is dispatched.
The problem is not just that context windows are getting bigger. It is that bigger windows make the cost boundary less visible to the application. A coding agent may attach a repository map, tool schemas, issue history, a policy document, and several failed patch attempts. Some of that input is stable enough to cache or hash. Some of it is fresh task text. Some of it is accidental baggage. If the SDK only returns token usage after the model call, the team learns about the shape of the request after it has already paid for the shape of the request.
I checked the live AIWave pricing feed before writing this.
/api/pricingreturnedsuccess=true, pricing versiona42d372ccf0b5dd13ecf71203521f9d2, and group ratios ofdefault=3andvip=1. The current DeepSeek rows exposed through AIWave include:deepseek-v4-flash:model_ratio=0.319,completion_ratio=3,cache_ratio=0.0318deepseek-v4-pro:model_ratio=0.957,completion_ratio=3,cache_ratio=0.0333I also rechecked the official DeepSeek pricing page during this run. It currently lists
deepseek-v4-flashanddeepseek-v4-prowith 1M context, 384K maximum output, separate cache-hit/cache-miss/output prices, and peak/off-peak windows. The visible USD table has Flash at$0.007/$0.014cache-hit input,$0.22/$0.44cache-miss input, and$0.66/$1.32output per 1M tokens for off-peak/peak. Pro is higher:$0.022/$0.044,$0.66/$1.32, and$1.98/$3.96on the same buckets.That makes prefix visibility a first-class SDK concern. A request with 700K cached repository tokens and 20K fresh task tokens is operationally different from a request with 720K uncached input, even if the model ID is identical. It is also different from a request that reserves too little output space and fails near the end of a tool-heavy plan.
The hint I have in mind is not an invoice. It is a pre-dispatch receipt:
{ "model": "deepseek-v4-pro", "context_limit": 1000000, "reserved_output_tokens": 64000, "fresh_input_estimate": 28000, "cacheable_prefix_estimate": 612000, "prefix_hash": "sha256:9b6f...", "pricing_source": "https://aiwave.live/api/pricing", "pricing_checked_at": "2026-08-29T14:12:22Z", "effective_group": "vip" }This would let the application decide whether to continue, split the job, refresh the prefix cache, downgrade the execution model, or ask a human to approve the request. It would also give support and finance a shared artifact when a customer asks why one agent run cost more than another.
QwenCloud's current pricing docs are another reason to do this outside a single-provider mental model. They describe per-million-token text billing, context-tiered request billing for some models, cache discounts, Batch API discounts, and thinking tokens billed as output. Z.AI's GLM pricing page has its own cached-input and output columns. A useful SDK abstraction should not hard-code one vendor's price table; it should expose the request shape, source timestamp, cache assumption, and selected billing group so the gateway can attach the current rates.
For
aiwave-sdk-python, I wonder if this belongs as an optional helper beforeclient.chat.completions.create, something like:The return value could be logged, used as a guardrail, or passed into the actual call as metadata. It should be easy to disable for small requests, but easy to require for background agents and batch jobs.
Discussion question: should long-context SDKs expose prefix budget hints before dispatch, or should this stay entirely inside gateway logs? I lean toward exposing it, because the application is usually where the bad prompt shape is created.
All reactions