Fix duplicate predefined tools in dynamic tools system message (#11101)

Fix duplicate predefined tools in dynamic system-message section
This commit is contained in:
MumuTW 2026-03-10 15:42:02 +09:00 • committed by GitHub
parent 1251ab9071
commit e63c5f8994
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -40,7 +40,7 @@ export const generateToolsSystemMessage = (
`\nAlso, these additional tool definitions show other tools you can call with the same syntax:`,
);
for (const tool of tools) {
for (const tool of withDynamicMessage) {
try {
const definition = framework.toolToSystemToolDefinition(tool);
instructions.push(`\n${definition}`);

View file

@ -191,6 +191,11 @@ describe("generateToolsSystemMessage", () => {
const hasDynamicToolsSection = /additional tool definitions/i.test(result);
expect(hasDynamicToolsSection).toBe(true);
// Dynamic definitions should not duplicate tools that already have predefined messages.
expect(result.match(/TOOL_NAME: tool_with_description/g)?.length ?? 0).toBe(
1,
);
});
it("includes example tool definition and call", () => {