Expand description
Capability and context-window guard for the routing / failover path.
RequiredCapabilities is derived from a ChatCompletionRequest and
checked against a candidate model’s ModelInfo before a route rewrite or
failover dispatch is committed. The check is intentionally permissive:
- When
ModelInfois unknown for a candidate (not in the registry catalog) we allow it through — we only skip when we positively know a capability is missing. - A capability that the request needs but the model info does not list causes the candidate to be skipped (the caller emits a tracing event and tries the next candidate or falls back to the original model).
§Token counting
[estimate_input_tokens] concatenates all message text and delegates to
[tt_tokenize::estimate_tokens], keyed on provider_id so tiktoken is
used for OpenAI/Anthropic and the char/4 heuristic is used elsewhere.
Image/audio bytes are not measured — the guard is a best-effort floor, not
an exact window-packing count.
Structs§
- Required
Capabilities - The set of capabilities a
ChatCompletionRequestrequires.
Functions§
- message_
text_ for_ estimation - Concatenate all message text parts from a request for token estimation.
- request_
has_ audio - True when any message carries an audio (
ContentPart::InputAudio) content part. - request_
has_ images - True when any message carries an image (
ContentPart::ImageUrl) content part. - request_
input_ text - Concatenated text of the user + system messages — the caller-controlled input, used for content/topic routing. Assistant/tool turns are excluded so a model’s own output can’t spuriously trigger a topic route.