Skip to content

Commit 8fed77b

Browse files
committed
perf(tools): wrap SearchConfig in Arc to reduce ToolContext clone cost
ToolContext is cloned on every tool execution. SearchConfig contains a HashMap which is expensive to clone. Wrapping it in Arc makes the clone a cheap reference count increment instead of a deep copy. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 63ea7e8 commit 8fed77b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

core/src/tools/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct ToolContext {
3232
/// Optional agent event sender for tools that emit high-level agent events (e.g., SubagentStart)
3333
pub agent_event_tx: Option<broadcast::Sender<crate::agent::AgentEvent>>,
3434
/// Optional search configuration for web_search tool
35-
pub search_config: Option<crate::config::SearchConfig>,
35+
pub search_config: Option<Arc<crate::config::SearchConfig>>,
3636
/// Optional sandbox for routing `bash` tool execution through A3S Box.
3737
pub sandbox: Option<std::sync::Arc<dyn crate::sandbox::BashSandbox>>,
3838
/// Optional command environment overrides for subprocess-based tools.
@@ -85,7 +85,7 @@ impl ToolContext {
8585

8686
/// Set the search configuration
8787
pub fn with_search_config(mut self, config: crate::config::SearchConfig) -> Self {
88-
self.search_config = Some(config);
88+
self.search_config = Some(Arc::new(config));
8989
self
9090
}
9191

0 commit comments

Comments
 (0)