Fix duplicate predefined tools in dynamic tools system message (#11101)
Fix duplicate predefined tools in dynamic system-message section
This commit is contained in:
parent
1251ab9071
commit
e63c5f8994
2 changed files with 6 additions and 1 deletions
|
|
@ -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}`);
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue