Skip to content

Commit 3abf1f5

Browse files
authored
feat(scripted_tool): add ScriptingToolSet with discovery mode support (everruns#534)
## Summary - Adds `ScriptingToolSet`, a higher-level wrapper around `ScriptedTool` that controls `system_prompt()` generation based on `DiscoveryMode` - **Exclusive mode** (default): full tool schemas in prompt — best when this is the only tool the LLM has - **WithDiscovery mode**: semantic descriptions only, LLM uses `discover` and `help` builtins — best for large tool sets or alongside other tools - Fixes pre-existing clippy warning in `mcp.rs` (unused `mut`) ## What - New `ScriptingToolSet` struct implementing the `Tool` trait, delegating execution to inner `ScriptedTool` - `ScriptingToolSetBuilder` with fluent API: `.tool()`, `.env()`, `.limits()`, `.short_description()`, `.with_discovery()` - `DiscoveryMode` enum (`Exclusive` | `WithDiscovery`) - Updated spec 014 with ScriptingToolSet documentation and module layout ## Why When `ScriptedTool` is used alongside other discovery-capable tools, full schemas in the system prompt waste tokens. `ScriptingToolSet` lets the caller choose: full schemas upfront (exclusive) or semantic-only with discover/help builtins (discovery mode). ## Test plan - [x] 17 unit tests covering both modes, prompt content, execution delegation, status callbacks, builtins, env vars, schemas - [x] `cargo fmt --check` passes - [x] `cargo clippy --all-targets -- -D warnings` passes - [x] `cargo test --all-features` passes (all 1575 tests) - [x] Feature-gated build with and without `scripted_tool` feature
1 parent e176196 commit 3abf1f5

4 files changed

Lines changed: 613 additions & 3 deletions

File tree

crates/bashkit/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,10 @@ pub use network::NetworkAllowlist;
397397
pub use tool::{BashTool, BashToolBuilder, Tool, ToolRequest, ToolResponse, ToolStatus, VERSION};
398398

399399
#[cfg(feature = "scripted_tool")]
400-
pub use scripted_tool::{ScriptedTool, ScriptedToolBuilder, ToolArgs, ToolCallback, ToolDef};
400+
pub use scripted_tool::{
401+
DiscoveryMode, ScriptedTool, ScriptedToolBuilder, ScriptingToolSet, ScriptingToolSetBuilder,
402+
ToolArgs, ToolCallback, ToolDef,
403+
};
401404

402405
#[cfg(feature = "http_client")]
403406
pub use network::HttpClient;

crates/bashkit/src/scripted_tool/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@
117117
//! the same `Arc<ToolCallback>` instances are reused across `execute()` calls.
118118
119119
mod execute;
120+
mod toolset;
121+
122+
pub use toolset::{DiscoveryMode, ScriptingToolSet, ScriptingToolSetBuilder};
120123

121124
use crate::ExecutionLimits;
122125
use std::sync::Arc;

0 commit comments

Comments
 (0)