pub fn apply_chunking(
markdown: &str,
budget: usize,
chunk: Option<usize>,
extra_fm: &[(&str, &str)],
) -> Result<String, String>Expand description
Apply chunking to a markdown response. Returns the chunk at idx (0-based)
with appropriate frontmatter metadata.
_chunk: N and _total_chunks: M are always injected (including
the 1 of 1 case) so an agent walking the surface can size
pagination without first peeking at the response length. A request
for chunk > total_chunks is always an error — even when the body
fits in a single chunk and the silent-cap behaviour would have
hidden the overshoot.