pub struct Agent { /* private fields */ }Expand description
The immutable, validated description of an agent.
Produced by AgentBuilder::build. It holds the value-first configuration
and materializes independent in-process runtimes from it, one per
session; the underlying runtime composition is kept in
private fields.
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn builder() -> AgentBuilder
pub fn builder() -> AgentBuilder
Start describing an agent.
§Example
use everruns::{Agent, Model};
let agent = Agent::builder()
.instructions("You are concise.")
.model(Model::simulated("Sure."))
.name("assistant")
.capability("test_math")
.parallel_tool_calls(true)
.build()?;Sourcepub fn session(&self) -> Session
pub fn session(&self) -> Session
Open a new, independent multi-turn Session with this
agent.
The session is lazy: the in-process runtime is assembled on the first
Session::send or
Session::inspect. Each session gets a fresh
id and isolated history. The Agent and its clones share the private
session catalog and event log so a dropped session can be resumed while
the Agent’s configured persistence lifecycle remains available.
Sourcepub async fn resume(
&self,
session_id: SessionId,
) -> Result<Session, ResumeError>
pub async fn resume( &self, session_id: SessionId, ) -> Result<Session, ResumeError>
Resume a session through this Agent’s configured session catalog.
The default catalog is Agent-lifetime memory and is shared by Agent
clones. With LocalConfig, the catalog and
canonical event log survive a new Agent and process. The resumed session
uses this Agent’s current model, instructions, tools, hooks, and
workspace configuration.
§Errors
Returns ResumeError when the id is unknown, the
configured catalog is unavailable, or persisted local state is corrupt.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Agent
impl !UnwindSafe for Agent
impl Freeze for Agent
impl Send for Agent
impl Sync for Agent
impl Unpin for Agent
impl UnsafeUnpin for Agent
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request