Skip to main content

parse_tools_call_envelope

Function parse_tools_call_envelope 

Source
pub fn parse_tools_call_envelope(envelope: &Value) -> Option<Value>
Expand description

Extract and parse the inner tool-result JSON from a tools/call response envelope.

Why: isolates the spike-verified unwrap (issue #2348: the daemon returns the tool result as a STRINGIFIED JSON blob inside result.content[0].text, not a nested Value) as one shared, testable step. Previously private to tools::recall_session (parse_recall_envelope); promoted here so session::memory_sink can reuse it (#2424). What: envelope is the raw result field of the JSON-RPC response (i.e. call_memory_tool_at’s Ok payload for a tools/call request). Returns Some(parsed_body) on a well-formed envelope, None otherwise (never panics on an unexpected shape). Test: tests::parse_tools_call_envelope_unwraps_stringified_content, tests::parse_tools_call_envelope_none_on_missing_content, tests::parse_tools_call_envelope_none_on_malformed_inner_json.