pub struct MockResponse {
pub text: String,
pub tool_call: Option<MockToolCall>,
pub stop_reason: String,
}Expand description
A single canned response produced by MockApiClient.
Each MockResponse describes exactly one assistant reply: the text
the model “says”, an optional tool call, and a stop reason. The mock
client translates these fields into the appropriate
StreamEvent sequence when stream_messages
is called.
§Construction
Build directly or via MockApiClient::with_responses:
use loopctl::testing::MockResponse;
let response = MockResponse {
text: "Done.".to_string(),
tool_call: None,
stop_reason: "end_turn".to_string(),
};Fields§
§text: StringThe text content the assistant should produce.
Emitted as a IndexedDelta event containing a
DeltaPart::Text variant. Defaults to "Hello!" when
constructed via MockApiClient::new.
The text is sent as a single delta — the mock does not break it
into chunks. If your test needs to verify incremental streaming,
construct the StreamEvent sequence manually.
tool_call: Option<MockToolCall>An optional tool call the assistant should make.
When present, the mock emits a second content block of type
MessagePart::ToolCall and sets the stop reason to
"tool_use". See MockToolCall for the fields involved.
Set to None for a plain text response. Set to Some(...) when
testing tool dispatch or multi-turn tool-call scenarios.
stop_reason: StringThe stop reason for this response.
Common values are "end_turn" (normal completion) and
"tool_use" (agent should execute a tool). Defaults to
"end_turn".
The agent loop uses this to decide whether to continue
processing or to finalize the session. Setting it to
"max_tokens" is useful for testing truncation handling.
Trait Implementations§
Source§impl Clone for MockResponse
impl Clone for MockResponse
Source§fn clone(&self) -> MockResponse
fn clone(&self) -> MockResponse
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more