feat: add max_turns to recipe and subagent settings#6687
Merged
katzdave merged 1 commit intoblock:mainfrom Jan 28, 2026
Merged
Conversation
1 task
Contributor
|
hi thanks for fixing!!! For the doc changes, could you kindly remove those? Only because your changes won't be released automatically...and the docs will be ahead of the release. |
Contributor
Author
|
@blackgirlbytes, documentation updates have been removed. |
katzdave
reviewed
Jan 26, 2026
crates/goose/src/agents/agent.rs
Outdated
| .and_then(|r| r.settings.as_ref()) | ||
| .and_then(|s| s.max_turns); | ||
|
|
||
| let task_config = TaskConfig::with_max_turns( |
Collaborator
There was a problem hiding this comment.
Typically this with_ pattern is used for chaining rather than a new constructor.
So I'd go something like:
TaskConfig::new(...).with_max_turns(max_turns_from_recipe)
| extensions: Vec<ExtensionConfig>, | ||
| max_turns_override: Option<usize>, | ||
| ) -> Self { | ||
| let max_turns = max_turns_override.or_else(|| { |
Collaborator
There was a problem hiding this comment.
we can leave this default case in the constructor as before.
with_max_turns can be something like:
pub fn with_max_turns(mut self, max_turns: Option<usize>) -> Self {
if let Some(turns) = max_turns {
self.max_turns = Some(turns);
}
self
}
| params: &SubagentParams, | ||
| ) -> Result<TaskConfig> { | ||
| if let Some(settings) = ¶ms.settings { | ||
| // Apply max_turns override if provided |
crates/goose/src/agents/agent.rs
Outdated
| let task_config = | ||
| TaskConfig::new(provider, &session.id, &session.working_dir, extensions); | ||
|
|
||
| // Extract max_turns from recipe settings if available |
katzdave
approved these changes
Jan 27, 2026
| } | ||
| } | ||
|
|
||
| // Note: The actual TaskConfig behavior is tested in crates/goose/tests/agent.rs |
Implements block#6198 Signed-off-by: Jonathan Hult <Jonathan@JonathanHult.com>
Collaborator
|
merging! |
eliasposen
pushed a commit
to eliasposen/goose
that referenced
this pull request
Jan 28, 2026
Signed-off-by: Jonathan Hult <Jonathan@JonathanHult.com> Signed-off-by: Elias Posen <elias@posen.ch>
This was referenced Jan 29, 2026
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
max_turnsfeature request from #6198. The feature allows controlling the maximum number of turns for subagents at multiple levels.All tests pass (541 tests), build succeeds, code formatted.
Implementation Details
Priority Order (highest to lowest)
settings.max_turnsin tool call)settings.max_turnsin recipe yaml)GOOSE_SUBAGENT_MAX_TURNS)Documentation
recipe-reference.mdwithmax_turnssettingenvironment-variables.mdwith override behaviorsubagents.mdxwith configuration examplesType of Change
AI Assistance
Testing
The existing
subagent_tool_tests.rstests focus on tool creation and schema validation, not runtime behavior. Testing the actualmax_turnsbehavior at runtime would require:max_turnslimitThis is more of an end-to-end test. Given the complexity and that we already have good coverage of the mechanics (constants, env var behavior, JSON schema), I think the current test coverage is reasonable. The real validation would happen in manual testing or as a separate end-to-end test suite.
Related Issues
Implements #6198