Refactor tool output into trait implementations (#14152)

First state to making tool outputs strongly typed (and `renderable`).
This commit is contained in:
pakrym-oai authored and GitHub committed 2026-03-09 19:38:32 -07:00
1 parent a5af11211a
commit aa04ea6bd7
24 files changed
+354 -344

No files matched your search

+6 -6
View File
@@ -3,15 +3,15 @@ use crate::client_common::tools::ToolSpec;
use crate::codex::Session;
use crate::codex::TurnContext;
use crate::function_tool::FunctionCallError;
use crate::tools::context::TextToolOutput;
use crate::tools::context::ToolInvocation;
use crate::tools::context::ToolOutput;
use crate::tools::context::ToolOutputBox;
use crate::tools::context::ToolPayload;
use crate::tools::registry::ToolHandler;
use crate::tools::registry::ToolKind;
use crate::tools::spec::JsonSchema;
use async_trait::async_trait;
use codex_protocol::config_types::ModeKind;
use codex_protocol::models::FunctionCallOutputBody;
use codex_protocol::plan_tool::UpdatePlanArgs;
use codex_protocol::protocol::EventMsg;
use std::collections::BTreeMap;
@@ -67,7 +67,7 @@ impl ToolHandler for PlanHandler {
ToolKind::Function
}
async fn handle(&self, invocation: ToolInvocation) -> Result<ToolOutput, FunctionCallError> {
async fn handle(&self, invocation: ToolInvocation) -> Result<ToolOutputBox, FunctionCallError> {
let ToolInvocation {
session,
turn,
@@ -88,10 +88,10 @@ impl ToolHandler for PlanHandler {
let content =
handle_update_plan(session.as_ref(), turn.as_ref(), arguments, call_id).await?;
Ok(ToolOutput::Function {
body: FunctionCallOutputBody::Text(content),
Ok(Box::new(TextToolOutput {
text: content,
success: Some(true),
})
}))
}
}