Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion crates/goose/src/agents/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,16 @@ impl Agent {
};

let extensions = self.get_extension_configs().await;

let max_turns_from_recipe = session
.recipe
.as_ref()
.and_then(|r| r.settings.as_ref())
.and_then(|s| s.max_turns);

let task_config =
TaskConfig::new(provider, &session.id, &session.working_dir, extensions);
TaskConfig::new(provider, &session.id, &session.working_dir, extensions)
.with_max_turns(max_turns_from_recipe);
let sub_recipes = self.sub_recipes.lock().await.clone();

let arguments = tool_call
Expand Down Expand Up @@ -1833,6 +1841,7 @@ impl Agent {
goose_provider: Some(provider_name.clone()),
goose_model: Some(model_name.clone()),
temperature: Some(model_config.temperature.unwrap_or(0.0)),
max_turns: None,
};

tracing::debug!(
Expand Down
7 changes: 7 additions & 0 deletions crates/goose/src/agents/subagent_task_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,11 @@ impl TaskConfig {
),
}
}

pub fn with_max_turns(mut self, max_turns: Option<usize>) -> Self {
if let Some(turns) = max_turns {
self.max_turns = Some(turns);
}
self
}
}
10 changes: 8 additions & 2 deletions crates/goose/src/agents/subagent_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct SubagentSettings {
pub provider: Option<String>,
pub model: Option<String>,
pub temperature: Option<f32>,
pub max_turns: Option<usize>,
}

pub fn create_subagent_tool(sub_recipes: &[SubRecipe]) -> Tool {
Expand Down Expand Up @@ -82,9 +83,10 @@ pub fn create_subagent_tool(sub_recipes: &[SubRecipe]) -> Tool {
"properties": {
"provider": {"type": "string", "description": "Override LLM provider"},
"model": {"type": "string", "description": "Override model"},
"temperature": {"type": "number", "description": "Override temperature"}
"temperature": {"type": "number", "description": "Override temperature"},
"max_turns": {"type": "number", "description": "Override max turns"}
},
"description": "Override model/provider settings."
"description": "Override model/provider/settings."
},
"summary": {
"type": "boolean",
Expand Down Expand Up @@ -392,6 +394,10 @@ async fn apply_settings_overrides(
params: &SubagentParams,
) -> Result<TaskConfig> {
if let Some(settings) = &params.settings {
if let Some(max_turns) = settings.max_turns {
task_config.max_turns = Some(max_turns);
}

if settings.provider.is_some() || settings.model.is_some() || settings.temperature.is_some()
{
let provider_name = settings
Expand Down
3 changes: 3 additions & 0 deletions crates/goose/src/recipe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ pub struct Settings {

#[serde(skip_serializing_if = "Option::is_none")]
pub temperature: Option<f32>,

#[serde(skip_serializing_if = "Option::is_none")]
pub max_turns: Option<usize>,
}

#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
Expand Down
5 changes: 5 additions & 0 deletions ui/desktop/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6087,6 +6087,11 @@
"type": "string",
"nullable": true
},
"max_turns": {
"type": "integer",
"nullable": true,
"minimum": 0
},
"temperature": {
"type": "number",
"format": "float",
Expand Down
1 change: 1 addition & 0 deletions ui/desktop/src/api/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ export type SetSlashCommandRequest = {
export type Settings = {
goose_model?: string | null;
goose_provider?: string | null;
max_turns?: number | null;
temperature?: number | null;
};

Expand Down