Skip to main content

Module budget

Module budget 

Source
Expand description

max_output_bytes enforcement: UTF-8-safe truncation and hit-list shrinking.

Budgeting always cuts on a structural boundary — a whole hit, or a char boundary inside markdown. Slicing raw JSON text would emit an unparseable document, which is strictly worse for an agent than an over-budget one.

Functions§

apply_output_budget_search_crates
Reduce search-crates hits until the success envelope fits max_output_bytes.
apply_output_budget_search_in_crate
Reduce search-in-crate hits until the success envelope fits max_output_bytes.
apply_truncation_to_item
Apply max_output_bytes truncation to get-item payload.
apply_truncation_to_readme
Apply max_output_bytes truncation to readme payload.
truncate_output
Truncate UTF-8 text on a char boundary; returns (text, truncated).