skilllite_agent/types/config.rs
1//! Agent configuration.
2
3/// Agent configuration.
4#[derive(Debug, Clone)]
5pub struct AgentConfig {
6 /// OpenAI-compatible API base URL (e.g. "https://api.openai.com/v1")
7 pub api_base: String,
8 /// API key
9 pub api_key: String,
10 /// Model name (e.g. "gpt-4o", "claude-3-5-sonnet-20241022")
11 pub model: String,
12 /// Maximum iterations for the agent loop
13 pub max_iterations: usize,
14 /// Maximum tool calls per task
15 pub max_tool_calls_per_task: usize,
16 /// Workspace root path
17 pub workspace: String,
18 /// System prompt override (optional)
19 pub system_prompt: Option<String>,
20 /// Temperature (0.0 - 2.0)
21 pub temperature: Option<f64>,
22 /// Skills directories to load (reserved for multi-dir support)
23 #[allow(dead_code)]
24 pub skill_dirs: Vec<String>,
25 /// Enable task planning
26 pub enable_task_planning: bool,
27 /// Enable memory tools
28 pub enable_memory: bool,
29 /// Enable memory vector search (requires memory_vector feature + embedding API)
30 pub enable_memory_vector: bool,
31 /// Verbose output
32 pub verbose: bool,
33 /// Path to SOUL.md identity document (optional).
34 /// Resolution: explicit path > .skilllite/SOUL.md > ~/.skilllite/SOUL.md
35 pub soul_path: Option<String>,
36
37 /// Optional extra context to append to system prompt (e.g. from RPC params.context.append).
38 /// Generic extension point for callers to inject domain-specific rules without modifying SkillLite.
39 pub context_append: Option<String>,
40
41 /// [Run mode] Max consecutive tool failures before stopping (prevents infinite retry loops).
42 /// None = no limit (chat mode). Some(N) = stop after N consecutive failures (run mode).
43 pub max_consecutive_failures: Option<usize>,
44
45 /// [Run mode] Extracted goal boundaries (scope, exclusions, completion conditions).
46 /// Injected into planning when set.
47 pub goal_boundaries: Option<crate::goal_boundaries::GoalBoundaries>,
48
49 /// When true, exclude conversation history from the planning prompt.
50 /// Use when each task is self-contained and history from previous turns would
51 /// corrupt planning (e.g. multi-turn agent orchestration, batch task dispatch).
52 /// Default: false.
53 pub skip_history_for_planning: bool,
54
55 /// Restrict the tool registry to read-only operations.
56 /// Used by replay/eval flows that must not mutate the workspace.
57 pub read_only_tools: bool,
58}
59
60impl Default for AgentConfig {
61 fn default() -> Self {
62 Self {
63 api_base: "https://api.openai.com/v1".to_string(),
64 api_key: String::new(),
65 model: "gpt-4o".to_string(),
66 max_iterations: 50,
67 max_tool_calls_per_task: 15,
68 workspace: std::env::current_dir()
69 .unwrap_or_else(|_| std::path::PathBuf::from("."))
70 .to_string_lossy()
71 .to_string(),
72 system_prompt: None,
73 temperature: None,
74 skill_dirs: Vec::new(),
75 enable_task_planning: true,
76 enable_memory: true,
77 enable_memory_vector: false,
78 verbose: false,
79 soul_path: None,
80 context_append: None,
81 max_consecutive_failures: None,
82 goal_boundaries: None,
83 skip_history_for_planning: false,
84 read_only_tools: false,
85 }
86 }
87}
88
89impl AgentConfig {
90 /// Load from environment variables with sensible defaults.
91 /// Also reads `.env` file from current directory if present.
92 /// Uses unified config layer: SKILLLITE_* with fallback to OPENAI_* / BASE_URL / API_KEY / MODEL.
93 pub fn from_env() -> Self {
94 skilllite_core::config::load_dotenv();
95 let llm = skilllite_core::config::LlmConfig::from_env();
96 let paths = skilllite_core::config::PathsConfig::from_env();
97 let flags = skilllite_core::config::AgentFeatureFlags::from_env();
98 Self {
99 api_base: llm.api_base,
100 api_key: llm.api_key,
101 model: llm.model,
102 workspace: paths.workspace,
103 enable_memory: flags.enable_memory,
104 enable_memory_vector: flags.enable_memory_vector,
105 enable_task_planning: flags.enable_task_planning,
106 ..Default::default()
107 }
108 }
109}