pub struct ToolSearchContext { /* private fields */ }Expand description
Context for tracking tool search state during input conversion.
This struct maintains:
pending_calls: Map of call_id -> tool_search_call items awaiting outputresolved_tools: Final merged tool list after processing all input itemspriority: Strategy for merging predefined and searched tools
Implementations§
Source§impl ToolSearchContext
impl ToolSearchContext
Sourcepub fn new(priority: ToolPriority) -> Self
pub fn new(priority: ToolPriority) -> Self
Create a new context with the given priority strategy.
Sourcepub fn register_search_call(&mut self, call_id: &str)
pub fn register_search_call(&mut self, call_id: &str)
Record that a tool_search_call was initiated with the given id.
Sourcepub fn is_registered_search(&self, call_id: &str) -> bool
pub fn is_registered_search(&self, call_id: &str) -> bool
Check if a call_id corresponds to a registered tool_search_call.
Sourcepub fn set_predefined_tools(&mut self, tools: Vec<Tool>)
pub fn set_predefined_tools(&mut self, tools: Vec<Tool>)
Set the predefined tools from the request.
This should be called once at the start of processing.
Sourcepub fn add_searched_tools(&mut self, tools: Vec<Tool>, call_id: &str)
pub fn add_searched_tools(&mut self, tools: Vec<Tool>, call_id: &str)
Add tools from a tool_search_output item.
The tools are collected but not yet merged - merging happens at finalize.
Sourcepub fn complete_search(&mut self, call_id: &str)
pub fn complete_search(&mut self, call_id: &str)
Mark the tool_search_call as completed (output received).
Currently a no-op since we don’t validate strict call_id matching, but could be used for future validation.
Sourcepub fn finalize(self) -> Vec<Tool>
pub fn finalize(self) -> Vec<Tool>
Finalize the context and resolve the final tool list.
This applies the priority strategy to merge predefined and searched tools. Returns the resolved tools and clears internal state.
Note: This method takes self by value and returns an owned Vec<Tool>.
Subsequent calls to resolved_tools() will return an empty vec.
Sourcepub fn resolved_tools(&self) -> &[Tool]
pub fn resolved_tools(&self) -> &[Tool]
Get the resolved tools without finalizing (for reading only).
Sourcepub fn priority(&self) -> ToolPriority
pub fn priority(&self) -> ToolPriority
Get the priority strategy.
Sourcepub fn has_pending_searches(&self) -> bool
pub fn has_pending_searches(&self) -> bool
Check if any searches are still pending (have output without a matching search).
Sourcepub fn predefined_count(&self) -> usize
pub fn predefined_count(&self) -> usize
Get count of predefined tools.
Sourcepub fn searched_count(&self) -> usize
pub fn searched_count(&self) -> usize
Get count of searched tools.
Trait Implementations§
Source§impl Clone for ToolSearchContext
impl Clone for ToolSearchContext
Source§fn clone(&self) -> ToolSearchContext
fn clone(&self) -> ToolSearchContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more