Skip to main content

ai_agents_runtime/optimization/
response.rs

1use ai_agents_core::ToolCall;
2
3/// Side-effect-free model output produced before a branch commits.
4#[derive(Debug, Clone)]
5pub enum MainResponseDraft {
6    Text {
7        raw_content: String,
8        thinking: Option<String>,
9    },
10    ToolCalls {
11        raw_content: String,
12        calls: Vec<ToolCall>,
13        thinking: Option<String>,
14    },
15}
16
17impl MainResponseDraft {
18    pub fn raw_content(&self) -> &str {
19        match self {
20            Self::Text { raw_content, .. } => raw_content,
21            Self::ToolCalls { raw_content, .. } => raw_content,
22        }
23    }
24
25    pub fn thinking(&self) -> Option<&str> {
26        match self {
27            Self::Text { thinking, .. } => thinking.as_deref(),
28            Self::ToolCalls { thinking, .. } => thinking.as_deref(),
29        }
30    }
31}