pub struct Agent {
pub info: AgentInfo,
pub provider: Arc<dyn Provider>,
pub tools: ToolRegistry,
pub permissions: HashMap<String, PermissionAction>,
/* private fields */
}Expand description
The main agent execution context
Fields§
§info: AgentInfo§provider: Arc<dyn Provider>§tools: ToolRegistry§permissions: HashMap<String, PermissionAction>Implementations§
Source§impl Agent
impl Agent
Sourcepub fn new(
info: AgentInfo,
provider: Arc<dyn Provider>,
tools: ToolRegistry,
system_prompt: String,
) -> Self
pub fn new( info: AgentInfo, provider: Arc<dyn Provider>, tools: ToolRegistry, system_prompt: String, ) -> Self
Create a new agent
Sourcepub async fn execute(
&self,
session: &mut Session,
prompt: &str,
) -> Result<AgentResponse>
pub async fn execute( &self, session: &mut Session, prompt: &str, ) -> Result<AgentResponse>
Execute a prompt and return the response
Sourcepub fn get_tool(&self, name: &str) -> Option<Arc<dyn Tool>>
pub fn get_tool(&self, name: &str) -> Option<Arc<dyn Tool>>
Get a tool from the registry by name
Sourcepub fn register_tool(&mut self, tool: Arc<dyn Tool>)
pub fn register_tool(&mut self, tool: Arc<dyn Tool>)
Register a tool with the agent’s tool registry
Sourcepub fn list_tools(&self) -> Vec<&str>
pub fn list_tools(&self) -> Vec<&str>
List all available tool IDs
Trait Implementations§
Source§impl Actor for Agent
Actor implementation for Agent - enables swarm participation
impl Actor for Agent
Actor implementation for Agent - enables swarm participation
Source§fn actor_status(&self) -> ActorStatus
fn actor_status(&self) -> ActorStatus
Get the actor’s current status
Source§impl Handler<SwarmMessage> for Agent
Handler implementation for SwarmMessage - enables message processing
impl Handler<SwarmMessage> for Agent
Handler implementation for SwarmMessage - enables message processing
Source§type Response = SwarmMessage
type Response = SwarmMessage
The response type for this handler
Auto Trait Implementations§
impl Freeze for Agent
impl !RefUnwindSafe for Agent
impl Send for Agent
impl Sync for Agent
impl Unpin for Agent
impl !UnwindSafe 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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more