Harden markup tag parsing to avoid mismatched-tag false positives

This commit is contained in:
CJACK.
2026-03-08 00:55:32 +08:00
parent 892213071a
commit 9b93badb57
4 changed files with 76 additions and 16 deletions

View File

@@ -249,3 +249,9 @@ test('formatOpenAIStreamToolCalls reuses ids with the same idStore', () => {
assert.equal(second.length, 1);
assert.equal(first[0].id, second[0].id);
});
test('parseToolCalls rejects mismatched markup tags', () => {
const payload = '<tool_call><name>read_file</function><arguments>{"path":"README.md"}</arguments></tool_call>';
const calls = parseToolCalls(payload, ['read_file']);
assert.equal(calls.length, 0);
});