Skip to main content

extract_last_assistant_text

Function extract_last_assistant_text 

Source
pub fn extract_last_assistant_text(
    store_path: &Path,
    max_chars: usize,
) -> Option<String>
Expand description

Extract the last assistant text message from a stored transcript JSONL.

Scans the file line by line (forward), keeping track of the last assistant text seen. Returns the final one, truncated to max_chars.

Expected format per line:

{"type":"assistant","message":{"content":[{"type":"text","text":"..."},{"type":"tool_use",...}]}}

Only extracts content blocks with "type":"text". Skips tool_use blocks.