Models, context and caching
Context limits how much content a request can process. Caching affects how repeated input is processed and billed. Changing client settings cannot expand upstream capacity.
What is a context window?
Context can include system instructions, conversation history, code, attachments, tool definitions, tool results and your new message. Space must also be reserved for model output.
Tokens are processing units, not characters or words. Chinese, English, code and images can be counted differently across models.
| Item | Meaning |
|---|---|
| Context window | Total context budget for a request |
| Maximum output | Limit for one generated reply, not the entire window |
| Client compaction threshold | When the client tries to summarize history, not upstream capacity |
| Request size limit | API or gateway limits for request bodies and attachments |
The model, upstream channel and client jointly constrain what is usable. Check Model Square. Ask support about limits that are not listed rather than inferring them from similar model names.
Can I increase client context settings?
Supported client settings control history management; they do not enlarge the model's real window. A value that is too high can cause limit errors, while a low value can trigger early compaction.
For settings such as model_context_window and model_auto_compact_token_limit, first check support in your Codex version, then use the actual model and channel limits. There is no fixed value suitable for every model.
If a request is too large, remove irrelevant history, long tool output or large attachments. Compact or start a new session at task boundaries. Before switching to a larger model, check permissions, pricing and tool compatibility.
Why can compaction lose details?
Compaction usually replaces some history with a summary. It cannot guarantee every requirement, screenshot detail or intermediate reasoning survives. Save a project handoff note containing:
- The goal and agreed constraints.
- Completed changes, file locations and verification results.
- Remaining steps, known issues and next actions.
Check those notes and the existing files before continuing. Compaction itself may require a model call. Earlier charges are not cleared, and later requests may need to rebuild the cache.
What is a cache hit?
Prompt caching generally reuses identical input prefixes from recent requests to reduce repeated processing. It does not store the previous answer or guarantee that the next call is free.
| Billing item | Meaning |
|---|---|
| Ordinary input | Tokens processed under ordinary input rules |
| Cache read / hit | Input tokens reused from a cache |
| Cache write / creation | Tokens used to build a cache, where supported |
| Output | Tokens generated for this request |
Xuo's backend supports cache-read and cache-write categories. Whether they appear, their lifetime and their price depend on the model, API, upstream channel and platform settings. Cache writes can have their own price; not every cache-related token is necessarily cheaper.
Why did caching miss or a model switch cost more?
Possible reasons include unsupported caching, unmet input conditions, expiration, changed prefixes, model or route changes, or a gateway that does not forward the required cache markers.
With an SDK, place stable instructions and reference material first and changing questions later. In Codex or Claude Code, avoid unnecessary model, tool configuration and provider changes. Do not retain irrelevant long history just to pursue cache hits.
Claude Code manages prompt caching automatically, but caching through a third-party gateway still depends on that gateway and its upstream. Do not copy another site's header toggle as a guarantee of cache hits.
Cache hits are not guaranteed. A slower or more expensive first turn after a model switch may reflect cache rebuilding; also check model prices, the actual group and input volume.
Should I subtract cached tokens from input?
There is no universal calculation for every API:
- OpenAI semantics: input totals usually include cached input. When cached input is priced separately, avoid charging it again at the ordinary input price.
- Anthropic semantics: ordinary input, cache reads and cache creation are generally reported separately. Do not subtract cached tokens from ordinary input again.
- Protocol conversion or other models: use the actual log fields and billing rules rather than field names alone.
The platform handles categories according to the API and billing rules. The example in how billing works uses a total that includes cached input; do not apply it unchanged to every Claude request.
Does long context always cost twice as much?
No. Some models or channels may use long-context tiers, separate cache-write prices or other charges. Whether these apply and their thresholds depend on Xuo's actual configuration.
Check Model Square and group multipliers before calling. Afterwards, review the model, actual group, input, output, caching and charge in Usage Logs. Report the time and request identifier for disputed charges without exposing business content or keys.
Official references: OpenAI prompt caching, Claude Code prompt caching. These do not replace Xuo's actual pricing.
