Skip to main content

phi_core/agents/
profile.rs

1use crate::types::ThinkingLevel;
2use serde::{Deserialize, Serialize};
3use std::path::PathBuf;
4
5/// A reusable agent blueprint that defines default configuration for agents.
6///
7/// Multiple agents can share the same profile, inheriting its settings as defaults.
8/// Agent-level settings (e.g. `system_prompt` on `BasicAgent`) override the profile's
9/// values when both are set.
10///
11/// ## Resolution order
12///
13/// For fields like `thinking_level` and `temperature`, the resolution order is:
14///   1. Session override (if set)
15///   2. Profile value (if set)
16///   3. Crate default (`ThinkingLevel::Off`, `None`)
17#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct AgentProfile {
19    /// Unique identifier for this profile. Auto-generated UUID when using `Default`.
20    #[serde(default = "default_profile_id")]
21    pub profile_id: String,
22
23    /// Human-readable name for agents using this profile.
24    #[serde(default)]
25    pub name: Option<String>,
26
27    /// Description of the profile's purpose or capabilities.
28    #[serde(default)]
29    pub description: Option<String>,
30
31    /// Default system prompt for agents using this profile.
32    /// Can be overridden at the agent level.
33    #[serde(default)]
34    pub system_prompt: Option<String>,
35
36    /// Default thinking level for agents using this profile.
37    #[serde(default)]
38    pub thinking_level: Option<ThinkingLevel>,
39
40    /// Default temperature for agents using this profile.
41    #[serde(default)]
42    pub temperature: Option<f32>,
43
44    /// Default max tokens for agents using this profile.
45    #[serde(default)]
46    pub max_tokens: Option<u32>,
47
48    /// Stable config identity. When set, used as the middle segment of `loop_id`:
49    ///   `loop_id = "{session_id}.{config_id}.{N}"`
50    #[serde(default)]
51    pub config_id: Option<String>,
52
53    /// Skill names loaded via `SkillSet` from SKILL.md files.
54    /// These are NOT tools — they are skill definitions per the AgentSkills standard.
55    #[serde(default)]
56    pub skills: Vec<String>,
57
58    /// Agent workspace directory. File paths in system prompt blocks resolve
59    /// relative to this directory.
60    #[serde(default)]
61    pub workspace: Option<PathBuf>,
62}
63
64fn default_profile_id() -> String {
65    uuid::Uuid::new_v4().to_string()
66}
67
68impl Default for AgentProfile {
69    fn default() -> Self {
70        Self {
71            profile_id: default_profile_id(),
72            name: None,
73            description: None,
74            system_prompt: None,
75            thinking_level: None,
76            temperature: None,
77            max_tokens: None,
78            config_id: None,
79            skills: Vec::new(),
80            workspace: None,
81        }
82    }
83}