Skip to content

Commit 1be5c5b

Browse files
committed
Changed: inline SchemaBuilder calls in each tool, remove centralized schema.rs
Move schema building from schema.rs helper functions directly into each tool's definition() method. This makes each tool self-contained with its own schema definition using raw SchemaBuilder calls. Affected tools: BashTool, TodoWriteTool, TodoReadTool, WebFetchTool, TaskTool
1 parent acce116 commit 1be5c5b

6 files changed

Lines changed: 91 additions & 205 deletions

File tree

src/llm-coding-tools-serdesai/src/bash.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
//! Provides cross-platform shell command execution with timeout support.
44
55
use crate::convert::to_serdes_result;
6-
use crate::schema::bash_schema;
76
use async_trait::async_trait;
87
use llm_coding_tools_core::context::ToolContext;
98
use llm_coding_tools_core::operations::execute_command;
109
use serde::Deserialize;
11-
use serdes_ai::tools::{RunContext, Tool, ToolDefinition, ToolError, ToolResult};
10+
use serdes_ai::tools::{RunContext, SchemaBuilder, Tool, ToolDefinition, ToolError, ToolResult};
1211
use std::path::{Path, PathBuf};
1312
use std::time::Duration;
1413

@@ -68,7 +67,31 @@ impl<Deps: Send + Sync> Tool<Deps> for BashTool {
6867
"Bash",
6968
"Execute a shell command with optional working directory and timeout.",
7069
)
71-
.with_parameters(bash_schema().expect("schema serialization should never fail"))
70+
.with_parameters(
71+
SchemaBuilder::new()
72+
.string_constrained(
73+
"command",
74+
"The shell command to execute",
75+
true,
76+
Some(1),
77+
None,
78+
None,
79+
)
80+
.string(
81+
"workdir",
82+
"Working directory for command execution (must be absolute path)",
83+
false,
84+
)
85+
.integer_constrained(
86+
"timeout_ms",
87+
"Timeout in milliseconds. Defaults to 120000 (2 minutes).",
88+
false,
89+
Some(1),
90+
Some(600_000),
91+
)
92+
.build()
93+
.expect("schema serialization should never fail"),
94+
)
7295
}
7396

7497
async fn call(&self, _ctx: &RunContext<Deps>, args: serde_json::Value) -> ToolResult {

src/llm-coding-tools-serdesai/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ pub mod task;
2626
pub mod todo;
2727
pub mod webfetch;
2828

29-
pub(crate) mod schema;
30-
3129
/// Re-export core types for convenience.
3230
pub use llm_coding_tools_core::{ToolError, ToolOutput, ToolResult};
3331

src/llm-coding-tools-serdesai/src/schema.rs

Lines changed: 0 additions & 187 deletions
This file was deleted.

src/llm-coding-tools-serdesai/src/task.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
//! Provides [`TaskTool`] for spawning sub-agents to handle complex tasks.
44
55
use crate::convert::to_serdes_result;
6-
use crate::schema::task_schema;
76
use async_trait::async_trait;
87
use llm_coding_tools_core::ToolOutput;
98
use llm_coding_tools_core::context::ToolContext;
109
use serde::Deserialize;
11-
use serdes_ai::tools::{RunContext, Tool, ToolDefinition, ToolError, ToolResult};
10+
use serdes_ai::tools::{RunContext, SchemaBuilder, Tool, ToolDefinition, ToolError, ToolResult};
1211
use std::sync::Arc;
1312

1413
/// Convenience re-exports from [`llm_coding_tools_core`] for users of this crate.
@@ -76,8 +75,19 @@ impl TaskTool<MockTaskExecutor> {
7675
#[async_trait]
7776
impl<Deps: Send + Sync, E: TaskExecutor + Send + Sync + 'static> Tool<Deps> for TaskTool<E> {
7877
fn definition(&self) -> ToolDefinition {
79-
ToolDefinition::new("Task", "Delegate a task to a specialized sub-agent.")
80-
.with_parameters(task_schema().expect("schema serialization should never fail"))
78+
ToolDefinition::new("Task", "Delegate a task to a specialized sub-agent.").with_parameters(
79+
SchemaBuilder::new()
80+
.string("description", "Short 3-5 word task description", true)
81+
.string("prompt", "Detailed instructions for the sub-agent", true)
82+
.string(
83+
"subagent_type",
84+
"Type of agent to use (e.g., \"general\", \"coder\")",
85+
true,
86+
)
87+
.string("session_id", "Existing session to continue", false)
88+
.build()
89+
.expect("schema serialization should never fail"),
90+
)
8191
}
8292

8393
async fn call(&self, _ctx: &RunContext<Deps>, args: serde_json::Value) -> ToolResult {

src/llm-coding-tools-serdesai/src/todo.rs

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
//! Provides tools for reading and writing todo items.
44
55
use crate::convert::to_serdes_result;
6-
use crate::schema::{todo_read_schema, todo_write_schema};
76
use async_trait::async_trait;
87
use llm_coding_tools_core::ToolOutput;
98
use llm_coding_tools_core::context::ToolContext;
109
use llm_coding_tools_core::operations::{read_todos, write_todos};
1110
use serde::Deserialize;
12-
use serdes_ai::tools::{RunContext, Tool, ToolDefinition, ToolError, ToolResult};
11+
use serdes_ai::tools::{RunContext, SchemaBuilder, Tool, ToolDefinition, ToolError, ToolResult};
1312

1413
// Re-export core types
1514
pub use llm_coding_tools_core::{Todo, TodoPriority, TodoState, TodoStatus};
@@ -44,8 +43,37 @@ impl TodoWriteTool {
4443
#[async_trait]
4544
impl<Deps: Send + Sync> Tool<Deps> for TodoWriteTool {
4645
fn definition(&self) -> ToolDefinition {
47-
ToolDefinition::new("TodoWrite", "Replace the todo list with new items.")
48-
.with_parameters(todo_write_schema().expect("schema serialization should never fail"))
46+
ToolDefinition::new("TodoWrite", "Replace the todo list with new items.").with_parameters(
47+
SchemaBuilder::new()
48+
.raw(
49+
"todos",
50+
serde_json::json!({
51+
"type": "array",
52+
"description": "The complete list of todos to set",
53+
"items": {
54+
"type": "object",
55+
"required": ["id", "content", "status", "priority"],
56+
"properties": {
57+
"id": { "type": "string", "description": "Unique identifier" },
58+
"content": { "type": "string", "description": "Task description" },
59+
"status": {
60+
"type": "string",
61+
"enum": ["pending", "in_progress", "completed", "cancelled"],
62+
"description": "Current status"
63+
},
64+
"priority": {
65+
"type": "string",
66+
"enum": ["high", "medium", "low"],
67+
"description": "Priority level"
68+
}
69+
}
70+
}
71+
}),
72+
true,
73+
)
74+
.build()
75+
.expect("schema serialization should never fail"),
76+
)
4977
}
5078

5179
async fn call(&self, _ctx: &RunContext<Deps>, args: serde_json::Value) -> ToolResult {
@@ -80,8 +108,11 @@ impl TodoReadTool {
80108
#[async_trait]
81109
impl<Deps: Send + Sync> Tool<Deps> for TodoReadTool {
82110
fn definition(&self) -> ToolDefinition {
83-
ToolDefinition::new("TodoRead", "Read the current todo list.")
84-
.with_parameters(todo_read_schema().expect("schema serialization should never fail"))
111+
ToolDefinition::new("TodoRead", "Read the current todo list.").with_parameters(
112+
SchemaBuilder::new()
113+
.build()
114+
.expect("schema serialization should never fail"),
115+
)
85116
}
86117

87118
async fn call(&self, _ctx: &RunContext<Deps>, args: serde_json::Value) -> ToolResult {

src/llm-coding-tools-serdesai/src/webfetch.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
//! Provides URL fetching with format conversion support.
44
55
use crate::convert::to_serdes_result;
6-
use crate::schema::webfetch_schema;
76
use async_trait::async_trait;
87
use llm_coding_tools_core::ToolOutput;
98
use llm_coding_tools_core::context::ToolContext;
109
use llm_coding_tools_core::operations::fetch_url;
1110
use serde::Deserialize;
12-
use serdes_ai::tools::{RunContext, Tool, ToolDefinition, ToolError, ToolResult};
11+
use serdes_ai::tools::{RunContext, SchemaBuilder, Tool, ToolDefinition, ToolError, ToolResult};
1312
use std::time::Duration;
1413

1514
/// Default timeout: 30 seconds.
@@ -66,7 +65,19 @@ impl<Deps: Send + Sync> Tool<Deps> for WebFetchTool {
6665
"WebFetch",
6766
"Fetch content from a URL. HTML is converted to markdown, JSON is prettified.",
6867
)
69-
.with_parameters(webfetch_schema().expect("schema serialization should never fail"))
68+
.with_parameters(
69+
SchemaBuilder::new()
70+
.string("url", "The URL to fetch", true)
71+
.integer_constrained(
72+
"timeout_ms",
73+
"Timeout in milliseconds. Defaults to 30000 (30 seconds).",
74+
false,
75+
Some(1),
76+
Some(600_000),
77+
)
78+
.build()
79+
.expect("schema serialization should never fail"),
80+
)
7081
}
7182

7283
async fn call(&self, _ctx: &RunContext<Deps>, args: serde_json::Value) -> ToolResult {

0 commit comments

Comments
 (0)