fix: normalize ollama tool calls from content and thinking

This commit is contained in:
lingyuzeng
2026-03-22 19:54:47 +08:00
parent 3f51c4a6b4
commit 8eb7b25ec9
6 changed files with 121 additions and 43 deletions

View File

@@ -45,4 +45,17 @@ hello
const result = parseXmlToolCalls(content);
expect(result).toHaveLength(0);
});
it('parses JSON tool calls wrapped in tool_call tags', () => {
const content = `
<tool_call>
{"name":"read","arguments":{"path":"/tmp/test.txt"}}
</tool_call>
`;
const result = parseXmlToolCalls(content);
expect(result).toHaveLength(1);
expect(result[0].name).toBe('read');
expect(result[0].args).toEqual({ path: '/tmp/test.txt' });
});
});