Skip to content

feat: Add max_turns to recipe and subagent settings #6198

@clouatre

Description

@clouatre

Please explain the motivation behind the feature request.

Subagents have a default max_turns limit of 25. Complex tasks (e.g., multi-file implementations with build/test verification) can exceed this limit, causing the subagent to stop with "I've reached the maximum number of actions I can do without user input."

Currently, the only way to configure this is via the GOOSE_SUBAGENT_MAX_TURNS environment variable, which:

  • Requires external setup before running goose
  • Applies globally to all subagents
  • Cannot be shared as part of a recipe

Describe the solution you'd like

Add max_turns field to:

  1. Settings struct in crates/goose/src/recipe/mod.rs - for top-level recipe configuration
  2. SubagentSettings struct in crates/goose/src/agents/subagent_tool.rs - for per-subagent configuration

This would allow recipes to specify:

settings:
  goose_provider: "gcp_vertex_ai"
  goose_model: "claude-sonnet-4-5@20250929"
  max_turns: 50

And subagent tool calls to override:

{
  "settings": {
    "model": "claude-haiku-4-5@20251001",
    "max_turns": 30
  }
}

Describe alternatives you've considered

Setting GOOSE_SUBAGENT_MAX_TURNS=50 in shell config. This works but is not portable across machines or shareable in recipes.

Additional context

Related: #3938 requested max turns for subagents but was closed before implementation. Since then, SubagentSettings was added with provider, model, temperature - adding max_turns would complete this.

Relevant code:

  • crates/goose/src/agents/subagent_task_config.rs - defines DEFAULT_SUBAGENT_MAX_TURNS (25) and reads env var

  • crates/goose/src/agents/subagent_tool.rs - apply_settings_overrides would need to handle max_turns

  • I have verified this does not duplicate an existing feature request

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestp2Priority 2 - Medium

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions