pub trait Agent:
Send
+ Sync
+ 'static {
Show 19 methods
// Required methods
fn new(
ma: ModularAgent,
id: String,
spec: AgentSpec,
) -> Result<Self, AgentError>
where Self: Sized;
fn ma(&self) -> &ModularAgent;
fn id(&self) -> &str;
fn status(&self) -> &AgentStatus;
fn spec(&self) -> &AgentSpec;
fn update_spec(&mut self, spec_update: &Value) -> Result<(), AgentError>;
fn def_name(&self) -> &str;
fn configs(&self) -> Result<&AgentConfigs, AgentError>;
fn set_config(
&mut self,
key: String,
value: AgentValue,
) -> Result<(), AgentError>;
fn set_configs(&mut self, configs: AgentConfigs) -> Result<(), AgentError>;
fn preset_id(&self) -> &str;
fn set_preset_id(&mut self, preset_id: String);
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn process<'life0, 'async_trait>(
&'life0 mut self,
ctx: AgentContext,
port: String,
value: AgentValue,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
// Provided methods
fn get_global_configs(&self) -> Option<AgentConfigs> { ... }
fn runtime(&self) -> &Runtime { ... }
}Expand description
The core trait for all agents.
All agents implement this trait. Defines lifecycle management, configuration access, and message processing.
Required Methods§
Sourcefn new(
ma: ModularAgent,
id: String,
spec: AgentSpec,
) -> Result<Self, AgentError>where
Self: Sized,
fn new(
ma: ModularAgent,
id: String,
spec: AgentSpec,
) -> Result<Self, AgentError>where
Self: Sized,
Constructs a new agent instance.
Sourcefn ma(&self) -> &ModularAgent
fn ma(&self) -> &ModularAgent
Returns the ModularAgent.
Sourcefn status(&self) -> &AgentStatus
fn status(&self) -> &AgentStatus
Returns the current lifecycle status.
Sourcefn update_spec(&mut self, spec_update: &Value) -> Result<(), AgentError>
fn update_spec(&mut self, spec_update: &Value) -> Result<(), AgentError>
Updates the agent specification.
Sourcefn configs(&self) -> Result<&AgentConfigs, AgentError>
fn configs(&self) -> Result<&AgentConfigs, AgentError>
Sourcefn set_config(
&mut self,
key: String,
value: AgentValue,
) -> Result<(), AgentError>
fn set_config( &mut self, key: String, value: AgentValue, ) -> Result<(), AgentError>
Sets a configuration value.
Sourcefn set_configs(&mut self, configs: AgentConfigs) -> Result<(), AgentError>
fn set_configs(&mut self, configs: AgentConfigs) -> Result<(), AgentError>
Sets the entire configuration.
Sourcefn set_preset_id(&mut self, preset_id: String)
fn set_preset_id(&mut self, preset_id: String)
Sets the preset ID.
Sourcefn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Starts the agent.
Called when the workflow starts. Use for initialization and initial output.
Sourcefn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stops the agent.
Sourcefn process<'life0, 'async_trait>(
&'life0 mut self,
ctx: AgentContext,
port: String,
value: AgentValue,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process<'life0, 'async_trait>(
&'life0 mut self,
ctx: AgentContext,
port: String,
value: AgentValue,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Processes an input message.
Called when the agent receives a value on an input port.
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Provided Methods§
Sourcefn get_global_configs(&self) -> Option<AgentConfigs>
fn get_global_configs(&self) -> Option<AgentConfigs>
Gets global configuration for this agent.