pub struct ScriptedTurn { /* private fields */ }Expand description
A single scripted model turn: an ordered list of text deltas and/or tool-calls, optionally reporting token usage on its terminal step.
Build one with the closure passed to MockConnectionBuilder::turn, or
construct directly and pass a Vec<ScriptedTurn> to
MockConnectionBuilder::turns.
Implementations§
Source§impl ScriptedTurn
impl ScriptedTurn
Sourcepub fn new() -> Self
pub fn new() -> Self
An empty turn. Add actions with Self::text / Self::tool_call.
Sourcepub fn text(self, text: impl Into<String>) -> Self
pub fn text(self, text: impl Into<String>) -> Self
Append a streamed text delta. Multiple text calls concatenate into
the turn-terminal step’s content (mirrors a streaming model emitting
deltas that sum to the final message).
Sourcepub fn tool_call(self, name: impl Into<String>, args: Value) -> Self
pub fn tool_call(self, name: impl Into<String>, args: Value) -> Self
Append a tool call the model “requests” at this point in the turn.
args is the JSON the tool receives. With a ToolRunner injected,
the mock executes it inline through the agent’s hooks + policies.
Sourcepub fn with_usage(self, usage: UsageMetadata) -> Self
pub fn with_usage(self, usage: UsageMetadata) -> Self
Report token usage on this turn’s terminal step (the only step that
carries usage — matching the live backends, so cumulative_usage
counts each turn exactly once).
Trait Implementations§
Source§impl Clone for ScriptedTurn
impl Clone for ScriptedTurn
Source§fn clone(&self) -> ScriptedTurn
fn clone(&self) -> ScriptedTurn
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more