Skip to main content

extract_text

Function extract_text 

Source
fn extract_text(value: &Value) -> String
Expand description

Mirrors extractText(value) - flattens a tool_result content payload into a single String. Accepts string, array of { type: "text", text } blocks, or a single object carrying prose under one of plan / description / summary / message / text (priority order: plan-mode-specific first, generic last).

Returns "" for any other shape so the caller knows the value can’t be rendered as user-facing text - the alternative (JSON-stringifying arbitrary structures) leaks raw \n escapes into chat (bug #136).