Expand description
Per-model context/output limits for recognized providers, so the agent can size context against the real window instead of guessing.
The provider’s own API does not expose a context window: the OpenCode Go
(zen) /models endpoint returns only id/object/created/owned_by, and rig
leaves Model::context_length empty for every OpenAI-compatible listing
(it is only populated for providers whose listing reports a window, e.g.
Groq/Moonshot/OpenRouter). The authoritative catalog is models.dev, whose
opencode-go entry (api = https://opencode.ai/zen/go/v1) carries
limit.context / limit.output per model. [OPENCODE_GO] is a snapshot of
that table.
The live measure of how full the context is comes from the provider’s own
response usage (prompt_tokens → crate::message::Usage::input_tokens),
not from here; these limits only say how much fits.
Structs§
- Model
Limit - Context window and output ceiling advertised for a model.
Constants§
- DEFAULT_
CONTEXT_ WINDOW - Context window assumed when neither the model catalog nor config supplies one: a conservative baseline so an unknown model still compacts in time.
- DEFAULT_
RESERVE_ CAP - Cap on how many tokens are held back for the model’s reply. The advertised
output ceiling can be huge (OpenCode’s
deepseek-v4.1-flashis 384k), so it is capped to keep most of the window usable for input.
Functions§
- is_
opencode_ go - True for endpoints served by OpenCode’s Go (zen) API.
- model_
limit - Limits for
modelserved frombase_url, when we recognize the provider.None= unknown provider/model (the caller falls back to a default budget).