Skip to content

Conversation

@jamadeo
Copy link
Collaborator

@jamadeo jamadeo commented Nov 20, 2025

If we present no tools to the model except a "execute subagent task" tool, the model will try to use that tool to do everything.

fixes #5812

Copilot AI review requested due to automatic review settings November 20, 2025 16:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors subagent enablement logic to prevent models from being given only subagent execution tools when no extensions are enabled. Previously, the logic was scattered across multiple files and primarily based on model name checks. The refactored approach centralizes the decision in a new Agent::subagents_enabled() method that considers three factors: autonomous mode, model compatibility (excluding gemini), and the presence of extensions.

Key changes:

  • Centralized subagent enablement logic into Agent::subagents_enabled() method
  • Removed should_enabled_subagents() function and model-name-based filtering
  • Modified SystemPromptBuilder to accept subagent enablement as a parameter rather than deriving it from model name

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
crates/goose/src/agents/agent.rs Added subagents_enabled() method with extension-based logic; updated list_tools() to conditionally include subagent tools; removed model_name parameter from prompt builder calls
crates/goose/src/agents/reply_parts.rs Removed model-name-based tool filtering; passed subagents_enabled() result to prompt builder
crates/goose/src/agents/recipe_tools/dynamic_task_tools.rs Removed should_enabled_subagents() function and unused imports
crates/goose/src/agents/prompt_manager.rs Refactored SystemPromptBuilder to accept subagents_enabled parameter directly instead of deriving from model name; updated all test cases accordingly

.provider()
.await
.map(|provider| provider.get_active_model_name().starts_with("gemini"))
.unwrap_or(true)
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If provider() returns an error, .unwrap_or(true) will disable subagents. This seems overly defensive - if we can't determine the model, we should probably allow subagents rather than assume it's gemini. Consider using .unwrap_or(false) instead.

Suggested change
.unwrap_or(true)
.unwrap_or(false)

Copilot uses AI. Check for mistakes.
}

pub async fn subagents_enabled(&self) -> bool {
let config = crate::config::Config::global();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that this is in the agent context (yeah!) we should be able to add the session_type to this too and not enable subagents if the session type is subagent. that way instead of failing the creation of a subagent when a subagent is trying to create one, it will not even know about it

Copy link
Collaborator

@alexhancock alexhancock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and would be good to get in

Copilot AI review requested due to automatic review settings December 15, 2025 16:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jamadeo jamadeo merged commit 9fdb035 into main Dec 15, 2025
18 checks passed
@jamadeo jamadeo deleted the jackamadeo/disallow-subagents-with-no-extensions branch December 15, 2025 17:45
zanesq added a commit that referenced this pull request Dec 15, 2025
* 'main' of github.com:block/goose: (22 commits)
  Disallow subagents with no extensions (#5825)
  chore(deps): bump js-yaml in /documentation (#6093)
  feat: external goosed server (#5978)
  fix: Make datetime info message more explicit to prevent LLM confusion about current year (#6101)
  refactor: unify subagent and subrecipe tools into single tool (#5893)
  goose repo is too big for the issue solver workflow worker (#6099)
  fix: use system not developer role in db (#6098)
  Add /goose issue solver github workflow (#6068)
  OpenAI responses streaming (#5837)
  Canonical models for Providers (#5694)
  feat: add Inception provider for Mercury models (#6029)
  fix old sessions with tool results not loading (#6094)
  Fix community page mobile responsiveness and horizontal overflow (#6082)
  Tool reply meta (#6074)
  chore: avoid accidentally using native tls again (#6086)
  Update vars to be capitalised to be in line with other variables in config file (#6085)
  docs: restructure recipe reference (#5972)
  docs: configure custom providers (#6044)
  docs: Community All-Stars Spotlight November 2025, CodeTV Hackathon edition (#6070)
  fix: include file attachments in queued messages (#5961)
  ...

# Conflicts:
#	crates/goose-server/src/routes/agent.rs
#	crates/goose/src/agents/extension_manager.rs
#	ui/desktop/src/api/sdk.gen.ts
fbalicchia pushed a commit to fbalicchia/goose that referenced this pull request Dec 16, 2025
aharvard added a commit that referenced this pull request Dec 16, 2025
…erer

* origin/main: (26 commits)
  Don't persist ephemeral extensions when resuming sessions (#5974)
  chore(deps): bump mdast-util-to-hast from 13.2.0 to 13.2.1 in /ui/desktop (#5939)
  chore(deps): bump node-forge from 1.3.1 to 1.3.2 in /documentation (#5898)
  Add Scorecard supply-chain security workflow (#5810)
  Don't show subagent tool when we're a subagent (#6125)
  Fix keyboard shortcut conflict for Focus Goose Window (#5809)
  feat(goose-cli): add feature to disable update (#5886)
  workflow: enable docs-update-recipe-ref (#6132)
  fix: filter tools in Ollama streaming when chat mode is enabled (#6118)
  feat(mcp): platform extension for "code mode" MCP tool calling (#6030)
  workflow: auto-update recipe-reference on release (#5988)
  Document recipe slash commands feature (#6075)
  docs: add GitHub Copilot device flow authentication details (#6123)
  Disallow subagents with no extensions (#5825)
  chore(deps): bump js-yaml in /documentation (#6093)
  feat: external goosed server (#5978)
  fix: Make datetime info message more explicit to prevent LLM confusion about current year (#6101)
  refactor: unify subagent and subrecipe tools into single tool (#5893)
  goose repo is too big for the issue solver workflow worker (#6099)
  fix: use system not developer role in db (#6098)
  ...
zanesq added a commit that referenced this pull request Dec 16, 2025
…sions

* 'main' of github.com:block/goose: (22 commits)
  Disallow subagents with no extensions (#5825)
  chore(deps): bump js-yaml in /documentation (#6093)
  feat: external goosed server (#5978)
  fix: Make datetime info message more explicit to prevent LLM confusion about current year (#6101)
  refactor: unify subagent and subrecipe tools into single tool (#5893)
  goose repo is too big for the issue solver workflow worker (#6099)
  fix: use system not developer role in db (#6098)
  Add /goose issue solver github workflow (#6068)
  OpenAI responses streaming (#5837)
  Canonical models for Providers (#5694)
  feat: add Inception provider for Mercury models (#6029)
  fix old sessions with tool results not loading (#6094)
  Fix community page mobile responsiveness and horizontal overflow (#6082)
  Tool reply meta (#6074)
  chore: avoid accidentally using native tls again (#6086)
  Update vars to be capitalised to be in line with other variables in config file (#6085)
  docs: restructure recipe reference (#5972)
  docs: configure custom providers (#6044)
  docs: Community All-Stars Spotlight November 2025, CodeTV Hackathon edition (#6070)
  fix: include file attachments in queued messages (#5961)
  ...

# Conflicts:
#	crates/goose-server/src/routes/agent.rs
#	crates/goose/src/agents/extension_manager.rs
#	ui/desktop/src/api/sdk.gen.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude sonnet 4 is very eager to create sub-agents, and goose does not handle it well

4 participants