Skip to main content

codex_tools/
tool_payload.rs

1use std::borrow::Cow;
2
3use codex_protocol::models::SearchToolCallParams;
4
5/// Canonical payload shapes accepted by model-visible tool runtimes.
6#[derive(Clone, Debug, PartialEq)]
7pub enum ToolPayload {
8    Function { arguments: String },
9    ToolSearch { arguments: SearchToolCallParams },
10    Custom { input: String },
11}
12
13impl ToolPayload {
14    pub fn log_payload(&self) -> Cow<'_, str> {
15        match self {
16            ToolPayload::Function { arguments } => Cow::Borrowed(arguments),
17            ToolPayload::ToolSearch { arguments } => Cow::Owned(arguments.query.clone()),
18            ToolPayload::Custom { input } => Cow::Borrowed(input),
19        }
20    }
21}