pub fn to_text(&self) -> String {
        let mut lines = String::new();

        for message in self.messages.iter() {
            match message {
                ContextMessage::Text(message) => {
                    lines.push_str(&format!("<message role=\"{}\">", message.role));
                    lines.push_str(&format!("<content>{}</content>", message.content));
                    if let Some(tool_calls) = &message.tool_calls {
                        for call in tool_calls {
                            lines.push_str(&format!(
                                "<forge_tool_call name=\"{}\"><![CDATA[{}]]></forge_tool_call>",
                                call.name,
                                serde_json::to_string(&call.arguments).unwrap()
                            ));
                        }
                    }

                    lines.push_str("</message>");
                }
                ContextMessage::Tool(result) => {
                    lines.push_str("<message role=\"tool\">");

                    lines.push_str(&format!(
                        "<forge_tool_result name=\"{}\"><![CDATA[{}]]></forge_tool_result>",
                        result.name,
                        serde_json::to_string(&result.output).unwrap()
                    ));
                    lines.push_str("</message>");
                }
                ContextMessage::Image(_) => {
                    lines.push_str("<image path=\"[base64 URL]\">".to_string().as_str());
                }
            }
        }

        format!("<chat_history>{lines}</chat_history>")
    }
Converts the context to textual format
crates/forge_domain/src/context.rs