pub struct ShadowMode { /* private fields */ }Expand description
Toggleable shadow-mode manager for agent tool calls.
Implementations§
Source§impl ShadowMode
impl ShadowMode
Sourcepub fn with_clock(
active: bool,
clock: impl Fn() -> f64 + Send + 'static,
) -> Self
pub fn with_clock( active: bool, clock: impl Fn() -> f64 + Send + 'static, ) -> Self
Create with a custom clock (useful for tests).
pub fn is_active(&self) -> bool
pub fn activate(&mut self)
pub fn deactivate(&mut self)
pub fn records(&self) -> &[ShadowRecord]
pub fn clear_records(&mut self)
Sourcepub fn intercept<F>(
&mut self,
tool_name: &str,
args: Value,
kwargs: Value,
when_shadow: Value,
f: F,
) -> Value
pub fn intercept<F>( &mut self, tool_name: &str, args: Value, kwargs: Value, when_shadow: Value, f: F, ) -> Value
Intercept a tool call.
If active: record the call, return when_shadow without calling f.
If inactive: call f and return its result.
args: positional args (usuallyjson!([arg1, arg2]))kwargs: keyword args (usuallyjson!({"key": val}))when_shadow: the placeholder to return in shadow modef: the real implementation (only called when inactive)
Sourcepub fn to_jsonl(&self, path: impl AsRef<Path>) -> Result<usize>
pub fn to_jsonl(&self, path: impl AsRef<Path>) -> Result<usize>
Save all records to path as JSONL (overwrites). Returns count.
Sourcepub fn load_jsonl(path: impl AsRef<Path>) -> Result<Vec<ShadowRecord>>
pub fn load_jsonl(path: impl AsRef<Path>) -> Result<Vec<ShadowRecord>>
Load records from a JSONL file.
Auto Trait Implementations§
impl Freeze for ShadowMode
impl !RefUnwindSafe for ShadowMode
impl Send for ShadowMode
impl !Sync for ShadowMode
impl Unpin for ShadowMode
impl UnsafeUnpin for ShadowMode
impl !UnwindSafe for ShadowMode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more