Skip to main content

FakeAgent

Struct FakeAgent 

Source
pub struct FakeAgent { /* private fields */ }
Expand description

An AgentBackend for tests: echoes, replies, fails or sleeps, and records its turns.

Implementations§

Source§

impl FakeAgent

Source

pub fn echo(name: &str) -> Self

Answers echo: <prompt>.

Source

pub fn replying(name: &str, text: &str) -> Self

Always answers text.

Source

pub fn failing(name: &str, retryable: bool) -> Self

Always fails.

Source

pub fn sleeping(name: &str, d: Duration) -> Self

Sleeps for d, then echoes.

Source

pub fn streaming( name: &str, progress: Vec<AgentProgress>, gap: Duration, text: &str, ) -> Self

Reports progress events gap apart, then answers text.

Source

pub fn with_session(self, session: &str) -> Self

Returns session as the native session id and declares resume support.

Source

pub fn enforcing(self, policies: &[ToolPolicy]) -> Self

Declares the tool policies it enforces.

Source

pub fn with_caps(self, caps: AgentCaps) -> Self

Declares native capabilities.

Source

pub fn calls(&self) -> usize

Number of turns started.

Source

pub fn turns(&self) -> Vec<AgentTurn>

The turns received, oldest first.

Trait Implementations§

Source§

impl AgentBackend for FakeAgent

Source§

fn name(&self) -> &str

Short name for logs and audit (claude, fallback(claude,codex)).
Source§

fn caps(&self) -> AgentCaps

What this backend supports natively.
Source§

fn run<'life0, 'async_trait>( &'life0 self, turn: AgentTurn, ) -> Pin<Box<dyn Future<Output = Result<AgentReply, AgentError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Runs one turn.
Source§

impl Debug for FakeAgent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.