pub struct AgentNode {
pub id: String,
pub description: String,
pub system_prompt: Option<String>,
pub can_return: bool,
pub can_handoff: bool,
pub allowed_targets: Vec<String>,
/* private fields */
}Expand description
An agent node in the handoff graph
Fields§
§id: StringAgent ID
description: StringAgent description
system_prompt: Option<String>System prompt for this agent
can_return: boolWhether this agent can return to caller
can_handoff: boolWhether this agent can hand off to others
allowed_targets: Vec<String>Allowed handoff targets (empty = all)
Implementations§
Source§impl AgentNode
impl AgentNode
Sourcepub fn new<F, Fut>(id: impl Into<String>, executor: F) -> Selfwhere
F: Fn(HandoffContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<AgentResponse, CrewError>> + Send + 'static,
pub fn new<F, Fut>(id: impl Into<String>, executor: F) -> Selfwhere
F: Fn(HandoffContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<AgentResponse, CrewError>> + Send + 'static,
Create a new agent node
Sourcepub fn description(self, desc: impl Into<String>) -> Self
pub fn description(self, desc: impl Into<String>) -> Self
Set description
Sourcepub fn system_prompt(self, prompt: impl Into<String>) -> Self
pub fn system_prompt(self, prompt: impl Into<String>) -> Self
Set system prompt
Sourcepub fn can_return(self) -> Self
pub fn can_return(self) -> Self
Allow this agent to return to caller
Sourcepub fn no_handoff(self) -> Self
pub fn no_handoff(self) -> Self
Prevent this agent from handing off
Sourcepub fn allowed_targets(self, targets: Vec<String>) -> Self
pub fn allowed_targets(self, targets: Vec<String>) -> Self
Restrict handoff targets
Sourcepub async fn execute(
&self,
context: HandoffContext,
) -> Result<AgentResponse, CrewError>
pub async fn execute( &self, context: HandoffContext, ) -> Result<AgentResponse, CrewError>
Execute the agent
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AgentNode
impl !RefUnwindSafe for AgentNode
impl Send for AgentNode
impl Sync for AgentNode
impl Unpin for AgentNode
impl UnsafeUnpin for AgentNode
impl !UnwindSafe for AgentNode
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