diff --git a/src/agent/oneshot.rs b/src/agent/oneshot.rs index 9c31307..b865363 100644 --- a/src/agent/oneshot.rs +++ b/src/agent/oneshot.rs @@ -165,6 +165,28 @@ impl AutoAgent { .map_err(|e| format!("{}: {}", self.name, e))?; if result.had_tool_calls { + // Extract output() calls from the conversation + let ctx = backend.0.context.lock().await; + for node in ctx.conversation() { + if let super::context::AstNode::Branch { children, .. } = node { + for child in children { + if let Some(leaf) = child.leaf() { + if let super::context::NodeBody::ToolCall { name, arguments } = leaf.body() { + if name == "output" { + if let Ok(args) = serde_json::from_str::(arguments) { + let key = args["key"].as_str().unwrap_or(""); + let value = args["value"].as_str().unwrap_or(""); + if !key.is_empty() { + self.outputs.insert(key.to_string(), value.to_string()); + } + } + } + } + } + } + } + } + drop(ctx); continue; }