Skip to main content

ares_agent/
config.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4// ============= Agent Configuration =============
5
6/// Agent configuration binding a model to tools and behavior.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct AgentConfig {
9    /// Reference to a model name defined in \[models\].
10    pub model: String,
11
12    /// System prompt for the agent (personality, instructions).
13    #[serde(default)]
14    pub system_prompt: Option<String>,
15
16    /// List of tool names this agent can use.
17    #[serde(default)]
18    pub tools: Vec<String>,
19
20    /// Optional whitelist of tool names this agent is allowed to use.
21    /// If absent, all tools are permitted.
22    #[serde(default, skip_serializing_if = "Option::is_none")]
23    pub allowed_tools: Option<Vec<String>>,
24
25    /// Maximum tool calling iterations before stopping (default: 10).
26    #[serde(default = "default_max_tool_iterations")]
27    pub max_tool_iterations: usize,
28
29    /// Whether to execute tool calls in parallel when possible.
30    #[serde(default)]
31    pub parallel_tools: bool,
32
33    /// Enable per-session history compaction ([`ares_llm::Compactor`]).
34    ///
35    /// Off by default; when on, long conversations are maintained as a
36    /// bounded working set (critical facts + rolling memory + recent turns)
37    /// instead of a naive last-5 history slice.
38    #[serde(default)]
39    pub compaction_enabled: Option<bool>,
40
41    /// Additional agent-specific configuration passed through.
42    #[serde(flatten)]
43    pub extra: HashMap<String, toml::Value>,
44}
45
46fn default_max_tool_iterations() -> usize {
47    10
48}