refactor: remove JSON-based tool call parsing from sieve and delete associated compatibility tests

This commit is contained in:
CJACK
2026-04-19 13:39:47 +08:00
parent 0c644d1f4d
commit c945f49fc4
26 changed files with 91 additions and 934 deletions

View File

@@ -129,7 +129,7 @@ test('parseChunkForContent keeps split response/content fragments inside respons
assert.equal(combined, '{"tool_calls":[{"name":"read_file","input":{"path":"README.MD"}}]}');
});
test('parseChunkForContent + sieve does not leak suspicious prefix in split tool json case', () => {
test('parseChunkForContent + sieve passes JSON tool payload through as text (XML-only)', () => {
const chunk = {
p: 'response',
v: [
@@ -146,15 +146,14 @@ test('parseChunkForContent + sieve does not leak suspicious prefix in split tool
events.push(...flushToolSieve(state, ['read_file']));
const hasToolCalls = events.some((evt) => evt.type === 'tool_calls' && evt.calls && evt.calls.length > 0);
const hasToolDeltas = events.some((evt) => evt.type === 'tool_call_deltas' && evt.deltas && evt.deltas.length > 0);
const leakedText = events
.filter((evt) => evt.type === 'text' && evt.text)
.map((evt) => evt.text)
.join('');
assert.equal(hasToolCalls || hasToolDeltas, true);
assert.equal(leakedText.includes('{'), false);
assert.equal(leakedText.toLowerCase().includes('tool_calls'), false);
// JSON payloads are no longer intercepted — they pass through as text.
assert.equal(hasToolCalls, false);
assert.equal(leakedText.includes('tool_calls'), true);
});
test('parseChunkForContent consumes nested item.v array payloads', () => {