Skip to main content

decode

Function decode 

Source
pub fn decode(body: &[u8]) -> Result<RunAgentInput>
Expand description

Parses a RunAgentInput from raw JSON bytes.

Before typed decoding, unknown protocol additions are removed and malformed known fields are rejected against the same schema used by client streams. What was removed is discarded; decode_with_warnings returns it.

The transport-free half of the extractor, for tests and for callers that already hold the body.

let input = decode(br#"{"threadId":"t","runId":"r","messages":[],"tools":[],"context":[]}"#)?;
assert_eq!(input.run_id.as_str(), "r");

assert!(decode(b"").is_err());
assert!(decode(b"{").is_err());