saya_agent/loop_runner/
output.rs1use crate::{AgentEvent, ProviderError, ToolMetadata};
2use thiserror::Error;
3
4#[derive(Debug, Clone, Copy)]
5pub struct AgentLimits {
6 pub max_turns: usize,
7 pub max_tool_calls: usize,
8}
9impl Default for AgentLimits {
10 fn default() -> Self {
11 Self {
12 max_turns: 12,
13 max_tool_calls: 24,
14 }
15 }
16}
17#[derive(Debug, Clone, PartialEq, Eq)]
18pub struct AgentOutput {
19 pub answer: String,
20 pub events: Vec<AgentEvent>,
21 pub used_bounded_sql_query: bool,
22 pub tool_metadata: Vec<ToolMetadata>,
23}
24#[derive(Debug, Error)]
25pub enum AgentError {
26 #[error("{0}")]
27 Provider(#[from] ProviderError),
28 #[error("agent limit reached: {0}")]
29 Limit(&'static str),
30 #[error("provider returned an unsupported tool call")]
31 InvalidToolCall,
32 #[error("conversation history is invalid")]
33 InvalidHistory,
34 #[error("conversation context exceeds the safe limit")]
35 ContextLimit,
36 #[error("request cancelled")]
37 Cancelled,
38}