Skip to main content

codex_tools/
tool_definition.rs

1use crate::JsonSchema;
2use serde_json::Value as JsonValue;
3
4/// Tool metadata and schemas that downstream crates can adapt into higher-level
5/// tool specs.
6#[derive(Debug, PartialEq)]
7pub struct ToolDefinition {
8    pub name: String,
9    pub description: String,
10    pub input_schema: JsonSchema,
11    pub output_schema: Option<JsonValue>,
12    pub defer_loading: bool,
13}
14
15impl ToolDefinition {
16    pub fn renamed(mut self, name: String) -> Self {
17        self.name = name;
18        self
19    }
20
21    pub fn into_deferred(mut self) -> Self {
22        self.output_schema = None;
23        self.defer_loading = true;
24        self
25    }
26}
27
28#[cfg(test)]
29#[path = "tool_definition_tests.rs"]
30mod tests;