Merge pull request #42 from CJackHwang/codex/fix-sieve-tool-call-filtering-issues

fix(node): 移除被过滤工具调用的回退重发并对齐 Go 行为
This commit is contained in:
CJACK.
2026-02-22 23:07:49 +08:00
committed by GitHub
2 changed files with 9 additions and 9 deletions

View File

@@ -263,14 +263,6 @@ function filterToolCalls(parsed, toolNames) {
}
out.push({ name: tc.name, input: tc.input || {} });
}
if (out.length === 0 && parsed.length > 0) {
for (const tc of parsed) {
if (!tc || !tc.name) {
continue;
}
out.push({ name: tc.name, input: tc.input || {} });
}
}
return out;
}

View File

@@ -52,11 +52,19 @@ test('parseToolCalls keeps non-object argument strings as _raw (Go parity)', ()
]);
});
test('parseToolCalls still intercepts unknown schema names to avoid leaks', () => {
test('parseToolCalls drops unknown schema names when toolNames is provided', () => {
const payload = JSON.stringify({
tool_calls: [{ name: 'not_in_schema', input: { q: 'go' } }],
});
const calls = parseToolCalls(payload, ['search']);
assert.equal(calls.length, 0);
});
test('parseToolCalls keeps unknown names when toolNames is empty', () => {
const payload = JSON.stringify({
tool_calls: [{ name: 'not_in_schema', input: { q: 'go' } }],
});
const calls = parseToolCalls(payload, []);
assert.equal(calls.length, 1);
assert.equal(calls[0].name, 'not_in_schema');
});