diff --git a/src/agent/oneshot.rs b/src/agent/oneshot.rs index b865363..9c31307 100644 --- a/src/agent/oneshot.rs +++ b/src/agent/oneshot.rs @@ -165,28 +165,6 @@ 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; } diff --git a/src/agent/tools/memory.rs b/src/agent/tools/memory.rs index 5c673cb..9abc712 100644 --- a/src/agent/tools/memory.rs +++ b/src/agent/tools/memory.rs @@ -245,13 +245,11 @@ fn output(args: &serde_json::Value) -> Result { anyhow::bail!("invalid output key: {}", key); } let value = get_str(args, "value")?; - // Write to disk if output dir is set (subprocess agents), - // otherwise just return success (forked agents extract from AST) - if let Ok(dir) = std::env::var("POC_AGENT_OUTPUT_DIR") { - let path = std::path::Path::new(&dir).join(&key); - std::fs::write(&path, &value) - .with_context(|| format!("writing output {}", path.display()))?; - } + let dir = std::env::var("POC_AGENT_OUTPUT_DIR") + .map_err(|_| anyhow::anyhow!("no output directory set"))?; + let path = std::path::Path::new(&dir).join(key); + std::fs::write(&path, value) + .with_context(|| format!("writing output {}", path.display()))?; Ok(format!("{}: {}", key, value)) }