diff --git a/config.agent.example.yaml b/config.agent.example.yaml index b0c3b08f..32ca55d5 100644 --- a/config.agent.example.yaml +++ b/config.agent.example.yaml @@ -2,10 +2,10 @@ # Location `/agents//config.yaml` model: openai:gpt-4o # Specify the LLM to use -temperature: null # Set default temperature parameter -top_p: null # Set default top-p parameter, range (0, 1) +temperature: null # Set default temperature parameter, range (0, 1) +top_p: null # Set default top-p parameter, with a range of (0, 1) or (0, 2) depending on the model use_tools: null # Which additional tools to use by agent. (e.g. 'fs,web_search') agent_prelude: null # Set a session to use when starting the agent. (e.g. temp, default) - +instructions: null # Override the instructions for the agent, have no effect for dynamic instructions variables: # Custom default values for the agent variables : diff --git a/config.example.yaml b/config.example.yaml index 470f93d2..aa26de7c 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -1,7 +1,7 @@ # ---- llm ---- model: openai:gpt-4o # Specify the LLM to use -temperature: null # Set default temperature parameter -top_p: null # Set default top-p parameter, range (0, 1) +temperature: null # Set default temperature parameter (0, 1) +top_p: null # Set default top-p parameter, with a range of (0, 1) or (0, 2) depending on the model # ---- behavior ---- stream: true # Controls whether to use the stream-style API. diff --git a/src/config/agent.rs b/src/config/agent.rs index d3f248e0..a666bdfe 100644 --- a/src/config/agent.rs +++ b/src/config/agent.rs @@ -173,8 +173,6 @@ impl Agent { } pub fn export(&self) -> Result { - let mut agent = self.clone(); - agent.definition.instructions = self.interpolated_instructions(); let mut value = json!({}); value["name"] = json!(self.name()); let variables = self.variables(); @@ -182,7 +180,9 @@ impl Agent { value["variables"] = serde_json::to_value(variables)?; } value["config"] = json!(self.config); - value["definition"] = json!(self.definition); + let mut definition = self.definition.clone(); + definition.instructions = self.interpolated_instructions(); + value["definition"] = json!(definition); value["functions_dir"] = Config::agent_functions_dir(&self.name) .display() .to_string() @@ -224,6 +224,7 @@ impl Agent { .session_dynamic_instructions .clone() .or_else(|| self.shared_dynamic_instructions.clone()) + .or_else(|| self.config.instructions.clone()) .unwrap_or_else(|| self.definition.instructions.clone()); for (k, v) in self.variables() { output = output.replace(&format!("{{{{{k}}}}}"), v) @@ -398,6 +399,8 @@ pub struct AgentConfig { pub use_tools: Option, #[serde(skip_serializing_if = "Option::is_none")] pub agent_prelude: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub instructions: Option, #[serde(default, skip_serializing_if = "IndexMap::is_empty")] pub variables: AgentVariables, } @@ -437,6 +440,9 @@ impl AgentConfig { if let Some(v) = read_env_value::(&with_prefix("agent_prelude")) { self.agent_prelude = v; } + if let Some(v) = read_env_value::(&with_prefix("instructions")) { + self.instructions = v; + } if let Ok(v) = env::var(with_prefix("variables")) { if let Ok(v) = serde_json::from_str(&v) { self.variables = v;