Skip to main content

escape_fence_body

Function escape_fence_body 

pub fn escape_fence_body(remote: &str) -> String
Expand description

Unwrap a JSON-RPC response into its result, validating the transport envelope. Fails on: missing/invalid jsonrpc version (must be "2.0"), response id mismatch (when expected_id is Some), ambiguous envelope (both result and error present), missing payload (neither result nor error), and a present non-success error. Escape the XML closing-tag trigger (</) in untrusted content before it is placed inside an <a2a-* ...> provenance wrapper, so a peer-controlled value containing a closing marker such as </a2a-artifact> cannot terminate the wrapper early. The wrapper is advisory provenance (the model is already told the interior is untrusted-external), but an inert <\/ keeps marker-looking content from confusing any downstream cursor/splitter. Defined here (the api crate) so both the inbound rpc_result error path and the outbound tool renderers share one canonical implementation.