use std::collections::VecDeque;
use std::sync::{Arc, Mutex};
use crate::message::AgentMessage;
use crate::tool::Tool;
use opi_ai::provider::Provider;
#[derive(Debug, thiserror::Error)]
pub enum AgentError {
#[error("provider error: {0}")]
Provider(String),
#[error("authentication failed: {0}")]
AuthFailed(String),
#[error("tool error: {0}")]
Tool(String),
#[error("hook error: {0}")]
Hook(String),
#[error("cancelled")]
Cancelled,
#[error("max turns exceeded ({0})")]
MaxTurnsExceeded(u32),
}
pub struct AgentLoopContext {
pub provider: Box<dyn Provider>,
pub tools: Vec<Box<dyn Tool>>,
pub messages: Vec<AgentMessage>,
pub model: String,
pub system: Option<String>,
pub steering_queue: Option<Arc<Mutex<VecDeque<String>>>>,
pub follow_up_queue: Option<Arc<Mutex<VecDeque<String>>>>,
}
#[derive(Debug, Clone)]
pub struct AgentLoopConfig {
pub max_turns: u32,
pub max_tokens: Option<u64>,
pub temperature: Option<f64>,
}
impl Default for AgentLoopConfig {
fn default() -> Self {
Self {
max_turns: 50,
max_tokens: None,
temperature: None,
}
}
}
pub struct AgentLoopTurnUpdate {
pub extra_messages: Vec<AgentMessage>,
}