fix(core): ensure default agents provide tools and use model-specific schemas (#24268)

This commit is contained in:
Abhi
2026-03-30 19:10:57 -04:00
committed by GitHub
parent 991dca4c40
commit 5b5f87abc7
2 changed files with 28 additions and 6 deletions

View File

@@ -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)', () => {

View File

@@ -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.