mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 02:24:09 -07:00
Refactor subagent delegation to be one tool per agent (#17346)
This commit is contained in:
committed by
GitHub
parent
07bd89399d
commit
2c6781d134
@@ -110,10 +110,22 @@ export class LocalAgentExecutor<TOutput extends z.ZodTypeAny> {
|
||||
runtimeContext.getMessageBus(),
|
||||
);
|
||||
const parentToolRegistry = runtimeContext.getToolRegistry();
|
||||
const allAgentNames = new Set(
|
||||
runtimeContext.getAgentRegistry().getAllAgentNames(),
|
||||
);
|
||||
|
||||
if (definition.toolConfig) {
|
||||
for (const toolRef of definition.toolConfig.tools) {
|
||||
if (typeof toolRef === 'string') {
|
||||
// Check if the tool is a subagent to prevent recursion.
|
||||
// We do not allow agents to call other agents.
|
||||
if (allAgentNames.has(toolRef)) {
|
||||
debugLogger.warn(
|
||||
`[LocalAgentExecutor] Skipping subagent tool '${toolRef}' for agent '${definition.name}' to prevent recursion.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the tool is referenced by name, retrieve it from the parent
|
||||
// registry and register it with the agent's isolated registry.
|
||||
const toolFromParent = parentToolRegistry.getTool(toolRef);
|
||||
|
||||
Reference in New Issue
Block a user