potato_agent/agents/
runner.rs1use crate::agents::{
2 error::AgentError, run_context::ResumeContext, session::SessionState, types::AgentResponse,
3};
4use async_trait::async_trait;
5use std::fmt::Debug;
6
7#[derive(Debug, Clone)]
9pub struct AgentRunResult {
10 pub final_response: AgentResponse,
11 pub iterations: u32,
12 pub completion_reason: String,
13 pub combined_text: Option<String>,
15}
16
17#[derive(Debug)]
19pub enum AgentRunOutcome {
20 Complete(Box<AgentRunResult>),
22 NeedsInput {
24 question: String,
25 resume_context: ResumeContext,
26 },
27}
28
29impl AgentRunOutcome {
30 pub fn complete(result: AgentRunResult) -> Self {
31 Self::Complete(Box::new(result))
32 }
33}
34
35#[async_trait]
37pub trait AgentRunner: Send + Sync + Debug {
38 fn id(&self) -> &str;
39
40 async fn run(
41 &self,
42 input: &str,
43 session: &mut SessionState,
44 ) -> Result<AgentRunOutcome, AgentError>;
45
46 async fn resume(
48 &self,
49 user_answer: &str,
50 ctx: ResumeContext,
51 session: &mut SessionState,
52 ) -> Result<AgentRunOutcome, AgentError>;
53}