mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-02 09:20:42 -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',
|
||||
configurable: true,
|
||||
});
|
||||
parentToolRegistry = new ToolRegistry(mockConfig, mockConfig.messageBus);
|
||||
parentToolRegistry.registerTool(
|
||||
new LSTool(mockConfig, mockConfig.messageBus),
|
||||
);
|
||||
const { messageBus } = mockConfig as unknown as { messageBus: MessageBus };
|
||||
parentToolRegistry = new ToolRegistry(mockConfig, messageBus);
|
||||
parentToolRegistry.registerTool(new LSTool(mockConfig, messageBus));
|
||||
parentToolRegistry.registerTool(
|
||||
new MockTool({ name: READ_FILE_TOOL_NAME }),
|
||||
);
|
||||
@@ -779,6 +778,25 @@ describe('LocalAgentExecutor', () => {
|
||||
// Assert that there is exactly ONE schema for this tool
|
||||
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)', () => {
|
||||
|
||||
@@ -1329,9 +1329,13 @@ export class LocalAgentExecutor<TOutput extends z.ZodTypeAny> {
|
||||
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.
|
||||
// Configure its schema based on whether output is expected.
|
||||
|
||||
Reference in New Issue
Block a user