tools: delete ToolOutput, dispatch returns String

ToolOutput was just { text: String } — replaced with plain String.
dispatch() and dispatch_shared() return String directly.
ActiveToolCall handle is (ToolCall, String).
Error results are prefixed with "Error: " by convention.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-04-04 16:08:59 -04:00 committed by Kent Overstreet
parent a24a6605b8
commit 37fad63ba9
3 changed files with 23 additions and 35 deletions

View file

@ -9,7 +9,7 @@
use crate::agent::api::ApiClient;
use crate::agent::api::types::*;
use crate::agent::tools::{self as agent_tools, ToolOutput};
use crate::agent::tools::{self as agent_tools};
use std::sync::OnceLock;
@ -181,17 +181,17 @@ pub async fn call_api_with_tools(
let prov = provenance.borrow().clone();
let output = match agent_tools::dispatch_shared(&call.function.name, &args, Some(&prov)).await {
Some(out) => out,
None => ToolOutput::error(format!("Unknown tool: {}", call.function.name)),
None => format!("Error: Unknown tool: {}", call.function.name),
};
if std::env::var("POC_AGENT_VERBOSE").is_ok() {
log(&format!("TOOL RESULT ({} chars):\n{}", output.text.len(), output.text));
log(&format!("TOOL RESULT ({} chars):\n{}", output.len(), output));
} else {
let preview: String = output.text.lines().next().unwrap_or("").chars().take(100).collect();
let preview: String = output.lines().next().unwrap_or("").chars().take(100).collect();
log(&format!("Result: {}", preview));
}
messages.push(Message::tool_result(&call.id, &output.text));
messages.push(Message::tool_result(&call.id, &output));
}
continue;
}