这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@abhipatel12
Copy link
Collaborator

TLDR

This PR introduces the necessary configuration and wiring to enable the experimental "Subagents" feature. It adds a new enableSubagents setting, updates the core Config to dynamically register subagents as tools when this setting is enabled, and ensures the MessageBus is correctly propagated for policy enforcement. It also resolves a circular dependency that was exposed by these changes.

Dive Deeper

Configuration Changes

  • Added a new boolean setting experimental.enableSubagents to the CLI settingsSchema. It defaults to false and requires a restart to take effect.
  • Updated both the CLI and Core Config classes to read and expose this setting.

Subagent Registration

  • In packages/core/src/config/config.ts, an AgentRegistry is now initialized.
  • The createToolRegistry method has been updated. If enableSubagents is true, it retrieves all agent definitions from the registry, wraps them in a SubagentToolWrapper, and registers them as tools.
  • This registration process respects the existing allowedTools and excludeTools configuration, allowing users to control which subagents are available.

Message Bus Propagation

  • Updated SubagentToolWrapper and SubagentInvocation to accept an optional MessageBus in their constructors.
  • The Config class now passes the MessageBus when creating the SubagentToolWrapper. This ensures that any actions taken by the subagents will still participate in the standard confirmation and policy enforcement flow.

Circular Dependency Fix

The introduction of AgentRegistry into Config exposed a circular dependency:
Config -> AgentRegistry -> CodebaseInvestigatorAgent -> GlobTool -> Config.

This was causing glob.test.ts to fail. The fix involved decoupling the tool name from the tool implementation:

  • Created packages/core/src/tools/tool-names.ts to hold tool name constants.
  • Updated GlobTool to use the constant GLOB_TOOL_NAME.
  • Updated CodebaseInvestigatorAgent to import the name from tool-names.ts instead of importing the GlobTool class, thus breaking the import cycle.

Reviewer Test Plan

1. Verify Unit Tests

Run preflight and ensure all tests pass

2. Verify Configuration Behavior

  1. Start the CLI without modifying settings. Verify that subagents are not loaded (you can check /tools to see if you see the example codebase investigator).
  2. Open your settings file and add:
    "experimental": {
      "enableSubagents": true
    }
  3. Restart the CLI. Verify that the codebase investigator is being registered now.

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

@abhipatel12 abhipatel12 requested a review from a team as a code owner September 26, 2025 20:09
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @abhipatel12, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request lays the foundational groundwork for integrating experimental subagents into the system. It introduces a new configuration option to enable this feature, sets up the necessary infrastructure for subagents to be recognized and utilized as tools, and ensures their operations adhere to existing policy enforcement mechanisms. A significant architectural improvement was also made by resolving a critical circular dependency, enhancing the modularity and stability of the codebase.

Highlights

  • Subagent Configuration and Registration: Introduced a new experimental setting, enableSubagents, which, when enabled, dynamically registers defined subagents as tools within the core Config.
  • Message Bus Integration for Subagents: Ensured that the MessageBus is correctly propagated to SubagentToolWrapper and SubagentInvocation to facilitate policy enforcement and confirmation flows for subagent actions.
  • Circular Dependency Resolution: Fixed a circular dependency involving Config, AgentRegistry, CodebaseInvestigatorAgent, and GlobTool by decoupling tool names from their implementations using a new tool-names.ts module.
  • New Subagent Module: Added a comprehensive new module for subagents, including AgentExecutor for running agent loops, AgentRegistry for managing agent definitions, SubagentInvocation for tool execution, and SubagentToolWrapper to expose subagents as standard tools.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the foundational components for the experimental "Subagents" feature. The changes are well-structured, adding a new configuration flag enableSubagents and the necessary logic in the Config class to dynamically register agent definitions as tools. The implementation of the AgentExecutor is robust, with good separation of concerns and important security considerations like an allowlist for non-interactive tools and runtime authorization checks. The introduction of a new AgentRegistry and the SubagentToolWrapper provides a clean abstraction for this new capability. Additionally, the PR thoughtfully addresses and resolves a circular dependency that was exposed by these changes. The new test suites for the agent components are comprehensive and cover many edge cases.

My review identifies one high-severity issue related to the generation of fallback IDs for tool calls, which could lead to collisions and incorrect agent behavior in rare but possible scenarios. A fix is suggested to ensure unique ID generation. Overall, this is a solid contribution that lays the groundwork for a powerful new feature.

@github-actions
Copy link

github-actions bot commented Sep 26, 2025

Size Change: +39.2 kB (+0.22%)

Total Size: 17.5 MB

Filename Size Change
./bundle/gemini.js 17.5 MB +39.2 kB (+0.22%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 830 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

@abhipatel12 abhipatel12 force-pushed the abhipatel12/add-agent-configuration branch from 047283f to 4b167da Compare September 29, 2025 17:07
useModelRouter,
enableMessageBusIntegration:
settings.tools?.enableMessageBusIntegration ?? false,
enableSubagents: settings.experimental?.enableSubagents ?? false,
Copy link
Contributor

@silviojr silviojr Oct 1, 2025

Choose a reason for hiding this comment

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

I think this should be fine for now, but it would be great to have a list where you list the subagents you want to enable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah that sounds great! I think as we discover a need for it, we can add more properties

for (const definition of agentDefinitions) {
// We must respect the main allowed/exclude lists for agents too.
const excludeTools = this.getExcludeTools() || [];
const allowedTools = this.getAllowedTools();
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm.. ok. So instead of having a list of enabled agents we are explicit considering them as tools and having the list of allowed/excluded here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, in the event that a user says they want to disable a subagent, we would need to respect that. For now, since we don't have a special flag --disable-subagent, we can respect it via the tool flag list.

- Adds `enableSubagents` to CLI and Core configuration.
- Updates `settingsSchema` to include the new setting.
- Updates `Config` in core to register subagents as tools when enabled.
- Updates `SubagentToolWrapper` and `AgentInvocation` to propagate the `messageBus`.
- Adds comprehensive tests for all new functionality.
- Fixes a circular dependency between `Config` and `GlobTool` by extracting the tool name to a new `tool-names.ts` constants file.
@abhipatel12 abhipatel12 force-pushed the abhipatel12/add-agent-configuration branch from 4b167da to e7fbf64 Compare October 1, 2025 20:41
@abhipatel12 abhipatel12 added this pull request to the merge queue Oct 1, 2025
Merged via the queue into main with commit 331ae7d Oct 1, 2025
24 of 26 checks passed
@abhipatel12 abhipatel12 deleted the abhipatel12/add-agent-configuration branch October 1, 2025 20:55
thacio added a commit to thacio/auditaria that referenced this pull request Oct 6, 2025
giraffe-tree pushed a commit to giraffe-tree/gemini-cli that referenced this pull request Oct 10, 2025
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.

3 participants