pub trait LifecycleManager: Send + Sync {
// Required methods
fn initialize_run(
&self,
session: &Session,
config: &AgentLoopConfig,
) -> AgentRuntimeState;
fn prepare_round<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'life7, 'life8, 'life9, 'life10, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
task_context: &'life2 mut Option<TaskLoopContext>,
runtime_state: &'life3 mut AgentRuntimeState,
round: usize,
max_rounds: usize,
config: &'life4 AgentLoopConfig,
cancel_token: &'life5 CancellationToken,
metrics_collector: Option<&'life6 MetricsCollector>,
session_id: &'life7 str,
model_name: &'life8 str,
tools: &'life9 dyn ToolExecutor,
llm: &'life10 dyn LLMProvider,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
'life6: 'async_trait,
'life7: 'async_trait,
'life8: 'async_trait,
'life9: 'async_trait,
'life10: 'async_trait;
fn handle_round_outcome<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
runtime_state: &'life2 mut AgentRuntimeState,
task_context: &'life3 mut Option<TaskLoopContext>,
round: usize,
should_break: bool,
) -> Pin<Box<dyn Future<Output = Result<bool, AgentError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn finalize_run<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
runtime_state: &'life2 mut AgentRuntimeState,
event_tx: &'life3 Sender<AgentEvent>,
session_id: &'life4 str,
config: &'life5 AgentLoopConfig,
metrics_collector: Option<&'life6 MetricsCollector>,
task_context: Option<TaskLoopContext>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
'life6: 'async_trait;
}Expand description
Manages agent run state machine and round transitions.
Required Methods§
Sourcefn initialize_run(
&self,
session: &Session,
config: &AgentLoopConfig,
) -> AgentRuntimeState
fn initialize_run( &self, session: &Session, config: &AgentLoopConfig, ) -> AgentRuntimeState
Initialize runtime state for a new agent run.
Sourcefn prepare_round<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'life7, 'life8, 'life9, 'life10, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
task_context: &'life2 mut Option<TaskLoopContext>,
runtime_state: &'life3 mut AgentRuntimeState,
round: usize,
max_rounds: usize,
config: &'life4 AgentLoopConfig,
cancel_token: &'life5 CancellationToken,
metrics_collector: Option<&'life6 MetricsCollector>,
session_id: &'life7 str,
model_name: &'life8 str,
tools: &'life9 dyn ToolExecutor,
llm: &'life10 dyn LLMProvider,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
'life6: 'async_trait,
'life7: 'async_trait,
'life8: 'async_trait,
'life9: 'async_trait,
'life10: 'async_trait,
fn prepare_round<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'life7, 'life8, 'life9, 'life10, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
task_context: &'life2 mut Option<TaskLoopContext>,
runtime_state: &'life3 mut AgentRuntimeState,
round: usize,
max_rounds: usize,
config: &'life4 AgentLoopConfig,
cancel_token: &'life5 CancellationToken,
metrics_collector: Option<&'life6 MetricsCollector>,
session_id: &'life7 str,
model_name: &'life8 str,
tools: &'life9 dyn ToolExecutor,
llm: &'life10 dyn LLMProvider,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
'life6: 'async_trait,
'life7: 'async_trait,
'life8: 'async_trait,
'life9: 'async_trait,
'life10: 'async_trait,
Prepare for a new round. Returns the round ID.
Sourcefn handle_round_outcome<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
runtime_state: &'life2 mut AgentRuntimeState,
task_context: &'life3 mut Option<TaskLoopContext>,
round: usize,
should_break: bool,
) -> Pin<Box<dyn Future<Output = Result<bool, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn handle_round_outcome<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
runtime_state: &'life2 mut AgentRuntimeState,
task_context: &'life3 mut Option<TaskLoopContext>,
round: usize,
should_break: bool,
) -> Pin<Box<dyn Future<Output = Result<bool, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Handle post-round processing and determine next action.
Returns true if the agent run should break out of the round loop.
Sourcefn finalize_run<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
runtime_state: &'life2 mut AgentRuntimeState,
event_tx: &'life3 Sender<AgentEvent>,
session_id: &'life4 str,
config: &'life5 AgentLoopConfig,
metrics_collector: Option<&'life6 MetricsCollector>,
task_context: Option<TaskLoopContext>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
'life6: 'async_trait,
fn finalize_run<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'async_trait>(
&'life0 self,
session: &'life1 mut Session,
runtime_state: &'life2 mut AgentRuntimeState,
event_tx: &'life3 Sender<AgentEvent>,
session_id: &'life4 str,
config: &'life5 AgentLoopConfig,
metrics_collector: Option<&'life6 MetricsCollector>,
task_context: Option<TaskLoopContext>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
'life6: 'async_trait,
Finalize the agent run.