mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-08 02:15:27 +08:00
fix: reset tool call state between separate tool blocks to ensure unique IDs across stream segments
This commit is contained in:
@@ -17,6 +17,7 @@ const {
|
||||
normalizePreparedToolNames,
|
||||
boolDefaultTrue,
|
||||
filterIncrementalToolCallDeltasByAllowed,
|
||||
resetStreamToolCallState,
|
||||
buildUsage,
|
||||
estimateTokens,
|
||||
shouldSkipPath,
|
||||
@@ -107,6 +108,16 @@ test('incremental and final tool formatting share stable id via idStore', () =>
|
||||
assert.equal(incremental[0].id, finalCalls[0].id);
|
||||
});
|
||||
|
||||
test('resetStreamToolCallState gives each completed block a fresh id', () => {
|
||||
const idStore = new Map();
|
||||
const first = formatIncrementalToolCallDeltas([{ index: 0, name: 'read_file' }], idStore);
|
||||
resetStreamToolCallState(idStore);
|
||||
const second = formatIncrementalToolCallDeltas([{ index: 0, name: 'search' }], idStore);
|
||||
assert.equal(first.length, 1);
|
||||
assert.equal(second.length, 1);
|
||||
assert.notEqual(first[0].id, second[0].id);
|
||||
});
|
||||
|
||||
test('formatIncrementalToolCallDeltas drops empty deltas (Go parity)', () => {
|
||||
const idStore = new Map();
|
||||
const formatted = formatIncrementalToolCallDeltas([{ index: 0 }], idStore);
|
||||
|
||||
Reference in New Issue
Block a user