mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
fix(core): ensure default agents provide tools and use model-specific schemas (#24268)
This commit is contained in:
@@ -348,10 +348,9 @@ describe('LocalAgentExecutor', () => {
|
|||||||
get: () => 'test-prompt-id',
|
get: () => 'test-prompt-id',
|
||||||
configurable: true,
|
configurable: true,
|
||||||
});
|
});
|
||||||
parentToolRegistry = new ToolRegistry(mockConfig, mockConfig.messageBus);
|
const { messageBus } = mockConfig as unknown as { messageBus: MessageBus };
|
||||||
parentToolRegistry.registerTool(
|
parentToolRegistry = new ToolRegistry(mockConfig, messageBus);
|
||||||
new LSTool(mockConfig, mockConfig.messageBus),
|
parentToolRegistry.registerTool(new LSTool(mockConfig, messageBus));
|
||||||
);
|
|
||||||
parentToolRegistry.registerTool(
|
parentToolRegistry.registerTool(
|
||||||
new MockTool({ name: READ_FILE_TOOL_NAME }),
|
new MockTool({ name: READ_FILE_TOOL_NAME }),
|
||||||
);
|
);
|
||||||
@@ -779,6 +778,25 @@ describe('LocalAgentExecutor', () => {
|
|||||||
// Assert that there is exactly ONE schema for this tool
|
// Assert that there is exactly ONE schema for this tool
|
||||||
expect(foundSchemas).toHaveLength(1);
|
expect(foundSchemas).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should provide tools to the model when toolConfig is OMITTED (default to all tools)', async () => {
|
||||||
|
const fullDefinition = createTestDefinition();
|
||||||
|
const { toolConfig: _, ...definition } = fullDefinition;
|
||||||
|
|
||||||
|
const executor = await LocalAgentExecutor.create(
|
||||||
|
definition as LocalAgentDefinition,
|
||||||
|
mockConfig,
|
||||||
|
onActivity,
|
||||||
|
);
|
||||||
|
|
||||||
|
const toolsList = (
|
||||||
|
executor as unknown as { prepareToolsList: () => FunctionDeclaration[] }
|
||||||
|
).prepareToolsList();
|
||||||
|
|
||||||
|
// Verify that LS_TOOL_NAME is in the list (since LS was registered in beforeEach)
|
||||||
|
const toolNames = toolsList.map((t) => t.name);
|
||||||
|
expect(toolNames).toContain(LS_TOOL_NAME);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('run (Execution Loop and Logic)', () => {
|
describe('run (Execution Loop and Logic)', () => {
|
||||||
|
|||||||
@@ -1329,9 +1329,13 @@ export class LocalAgentExecutor<TOutput extends z.ZodTypeAny> {
|
|||||||
toolsList.push(toolRef);
|
toolsList.push(toolRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add schemas from tools that were explicitly registered by name, wildcard, or instance.
|
|
||||||
toolsList.push(...this.toolRegistry.getFunctionDeclarations());
|
|
||||||
}
|
}
|
||||||
|
// Add schemas from tools that were explicitly registered by name, wildcard, or instance.
|
||||||
|
toolsList.push(
|
||||||
|
...this.toolRegistry.getFunctionDeclarations(
|
||||||
|
this.definition.modelConfig.model,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
// Always inject complete_task.
|
// Always inject complete_task.
|
||||||
// Configure its schema based on whether output is expected.
|
// Configure its schema based on whether output is expected.
|
||||||
|
|||||||
Reference in New Issue
Block a user