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

@ -602,7 +602,7 @@ impl Agent {
if call.function.name == "working_stack" {
let mut me = agent.lock().await;
let result = tools::working_stack::handle(&args, &mut me.context.working_stack);
let output = tools::ToolOutput::text(result.clone());
let output = result.clone();
me.apply_tool_result(call, output, ui_tx, ds);
if !result.starts_with("Error:") {
me.refresh_context_state();
@ -643,7 +643,7 @@ impl Agent {
fn apply_tool_result(
&mut self,
call: &ToolCall,
output: tools::ToolOutput,
output: String,
ui_tx: &UiSender,
ds: &mut DispatchState,
) {
@ -651,20 +651,20 @@ impl Agent {
serde_json::from_str(&call.function.arguments).unwrap_or_default();
ds.had_tool_calls = true;
if output.text.starts_with("Error:") {
if output.starts_with("Error:") {
ds.tool_errors += 1;
}
let _ = ui_tx.send(UiMessage::ToolResult {
name: call.function.name.clone(),
result: output.text.clone(),
result: output.clone(),
});
self.active_tools.lock().unwrap().retain(|t| t.id != call.id);
// Tag memory_render results for context deduplication
if call.function.name == "memory_render" && !output.text.starts_with("Error:") {
if call.function.name == "memory_render" && !output.starts_with("Error:") {
if let Some(key) = args.get("key").and_then(|v| v.as_str()) {
let mut msg = Message::tool_result(&call.id, &output.text);
let mut msg = Message::tool_result(&call.id, &output);
msg.stamp();
self.push_entry(ConversationEntry::Memory { key: key.to_string(), message: msg });
self.publish_context_state();
@ -672,7 +672,7 @@ impl Agent {
}
}
self.push_message(Message::tool_result(&call.id, &output.text));
self.push_message(Message::tool_result(&call.id, &output));
}
/// Build context state summary for the debug screen.