pub fn parse_structured<T: KlieoResponse>(content: &str) -> Result<T, Error>Expand description
Parse an LLM reply (raw text content) into a typed T.
Tolerates surrounding markdown code-fences (```json ... ```
or bare ``` ... ```) and leading / trailing whitespace.
Many providers wrap JSON in fences despite being asked for raw JSON;
this helper papers over that.
§Size cap
Inputs larger than MAX_PARSE_INPUT_BYTES are rejected before any
allocation-heavy parsing runs, so a hostile or runaway provider
cannot push the host into multi-megabyte allocations on every reply.
§Errors
Returns Error::BadResponse on any deserialization failure. The
payload is intentionally position-only (line / col) — the
raw serde_json::Error::Display body would echo attacker- or
LLM-controlled byte fragments into the run-log / OTLP traces, which
matters in compliance deployments. The variant is permanent
(retryable() == false); retrying the same reply will fail
identically. Callers wishing to retry should request a fresh
completion with a tighter prompt or schema.