pub struct MockProvider { /* private fields */ }Implementations§
Source§impl MockProvider
impl MockProvider
Sourcepub fn with_usage(scripted: Vec<Completion>) -> Self
pub fn with_usage(scripted: Vec<Completion>) -> Self
Alias for new — both accept completions that may have usage set.
Provided for API symmetry when callers want to be explicit about usage.
Sourcepub fn new(scripted: Vec<Completion>) -> Self
pub fn new(scripted: Vec<Completion>) -> Self
Create a new MockProvider with the given scripted completions.
Sourcepub fn with_on_complete(self, notify: Arc<Notify>) -> Self
pub fn with_on_complete(self, notify: Arc<Notify>) -> Self
Attach a notifier that fires once per complete() call, after the
completion is dequeued and immediately before it is returned. Tests
use this to deterministically synchronise external side-effects
(e.g. cancellation) with agent progress, avoiding wall-clock sleeps.
Sourcepub fn with_on_complete_fn<F>(self, hook: F) -> Self
pub fn with_on_complete_fn<F>(self, hook: F) -> Self
Attach a synchronous hook that runs once per complete() call, after
the completion is dequeued and immediately before it is returned.
Sourcepub fn with_errors(self, errors: Vec<Error>) -> Self
pub fn with_errors(self, errors: Vec<Error>) -> Self
Set a queue of errors to return from complete() before the scripted
completions are consumed. Each call to complete() pops the next error;
when the error queue is empty, scripted completions are returned as usual.
Sourcepub fn calls(&self) -> Vec<Vec<Message>>
pub fn calls(&self) -> Vec<Vec<Message>>
Snapshot of the transcripts the agent has sent to this provider.
Sourcepub fn with_structured_responses(self, responses: Vec<Result<Value>>) -> Self
pub fn with_structured_responses(self, responses: Vec<Result<Value>>) -> Self
Set the queue of structured responses for complete_structured.
Each call to complete_structured pops the next response.
If the queue is empty, it returns an error (fallback path).
Trait Implementations§
Source§impl ChatProvider for MockProvider
impl ChatProvider for MockProvider
fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
_tools: &'life2 [ToolSpec],
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn complete_structured<'life0, 'async_trait>(
&'life0 self,
_req: StructuredRequest,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete_structured<'life0, 'async_trait>(
&'life0 self,
_req: StructuredRequest,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
stream_tx: Option<StreamSender>,
_cancel_token: Option<CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
stream_tx: Option<StreamSender>,
_cancel_token: Option<CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn supports_deferred_tools(&self) -> bool
fn supports_deferred_tools(&self) -> bool
tool_reference content blocks (Anthropic API feature). Read moreSource§fn complete_with_search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
eager_tools: &'life2 [(ToolSpec, Option<String>)],
deferred_tools: &'life3 [(ToolSpec, Option<String>)],
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn complete_with_search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
eager_tools: &'life2 [(ToolSpec, Option<String>)],
deferred_tools: &'life3 [(ToolSpec, Option<String>)],
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
defer_loading: true + tool_reference content
blocks) override this. The default implementation concatenates
the two lists (dropping the hints) and calls complete() —
i.e., it ignores the partition and behaves identically to the
legacy interface. Read moreSource§fn stream_with_search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
eager_tools: &'life2 [(ToolSpec, Option<String>)],
deferred_tools: &'life3 [(ToolSpec, Option<String>)],
stream_tx: Option<StreamSender>,
cancel_token: Option<CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn stream_with_search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
eager_tools: &'life2 [(ToolSpec, Option<String>)],
deferred_tools: &'life3 [(ToolSpec, Option<String>)],
stream_tx: Option<StreamSender>,
cancel_token: Option<CancellationToken>,
) -> Pin<Box<dyn Future<Output = Result<Completion>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
ToolSearchTool;
deferred tools become available only after the model requests them. Read more