pub struct Agent<M>where
M: ModelAdapter,{ /* private fields */ }Expand description
A configured agent ready to start a session.
Build one with Agent::builder, supplying at minimum a ModelAdapter.
Then call Agent::start with a SessionConfig to obtain a
LoopDriver that drives the agentic loop.
§Example
use agentkit_loop::{
Agent, LoopStep, PromptCacheRequest, PromptCacheRetention, SessionConfig,
};
use agentkit_tools_core::ToolRegistry;
let agent = Agent::builder()
.model(adapter)
.tools(ToolRegistry::new())
.build()?;
let mut driver = agent
.start(
SessionConfig::new("s1").with_cache(
PromptCacheRequest::automatic().with_retention(PromptCacheRetention::Short),
),
)
.await?;
// Submit input and advanceImplementations§
Source§impl<M> Agent<M>where
M: ModelAdapter,
impl<M> Agent<M>where
M: ModelAdapter,
Sourcepub fn builder() -> AgentBuilder<M>
pub fn builder() -> AgentBuilder<M>
Create a new AgentBuilder for configuring this agent.
Sourcepub async fn start(
self,
config: SessionConfig,
) -> Result<LoopDriver<M::Session>, LoopError>
pub async fn start( self, config: SessionConfig, ) -> Result<LoopDriver<M::Session>, LoopError>
Consume the agent and start a new session, returning a LoopDriver.
This calls ModelAdapter::start_session and emits an
AgentEvent::RunStarted event to all registered observers.
§Errors
Returns LoopError if the model adapter fails to create a session.
Auto Trait Implementations§
impl<M> Freeze for Agent<M>where
M: Freeze,
impl<M> !RefUnwindSafe for Agent<M>
impl<M> Send for Agent<M>
impl<M> !Sync for Agent<M>
impl<M> Unpin for Agent<M>where
M: Unpin,
impl<M> UnsafeUnpin for Agent<M>where
M: UnsafeUnpin,
impl<M> !UnwindSafe for Agent<M>
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