Skip to main content

enforce_response_budget

Function enforce_response_budget 

Source
pub fn enforce_response_budget(
    output: &FetchOutput,
    budget_tokens: usize,
) -> Result<usize, RssError>
Expand description

Check output against a token budget, returning the estimate on success.

On overflow, returns RssError::ResponseTooLarge carrying concrete, machine-readable retry suggestions (a smaller limit and a max_content_chars) so the calling agent can self-recover instead of giving up. This is the cap-and-error path; it never mutates output.