@@ -45,6 +45,10 @@ const fragments = {
4545 B : [ '{"path":"scope-' , 'b.ts"}' ] ,
4646} satisfies Record < ScopeId , readonly [ string , string ] >
4747
48+ const STREAMING_TOOL_NAME = "read_file"
49+ const streamingKey = ( scopeId : ScopeId ) : string =>
50+ NativeToolCallParser . makeStreamingKey ( callIds [ scopeId ] , STREAMING_TOOL_NAME )
51+
4852const expectedActions = new Set < LocalAction > ( localActions )
4953const reachedActions = new Set < LocalAction > ( )
5054const reachedLandmarks = new Set < string > ( )
@@ -128,7 +132,7 @@ function replayAction(state: ReplayState, scheduled: ScheduledAction): void {
128132 assert . deepEqual ( events , [ { type : "tool_call_delta" , id : callIds [ scopeId ] , delta : fragment } ] )
129133 appendOwnedEvents ( state , scopeId , events )
130134 assert . notEqual (
131- NativeToolCallParser . processStreamingChunk ( callIds [ scopeId ] , fragment , scope ) ,
135+ NativeToolCallParser . processStreamingChunk ( streamingKey ( scopeId ) , fragment , scope ) ,
132136 null ,
133137 `${ scopeId } 's fragment was not accepted by its streaming accumulator` ,
134138 )
@@ -138,7 +142,7 @@ function replayAction(state: ReplayState, scheduled: ScheduledAction): void {
138142 case "finalize-raw-call" : {
139143 const scope = requireScope ( state , scopeId )
140144 const events = NativeToolCallParser . finalizeRawChunks ( scope )
141- assert . deepEqual ( events , [ { type : "tool_call_end" , id : callIds [ scopeId ] } ] )
145+ assert . deepEqual ( events , [ { type : "tool_call_end" , id : callIds [ scopeId ] , name : STREAMING_TOOL_NAME } ] )
142146 appendOwnedEvents ( state , scopeId , events )
143147 scopeState . rawEndCount += events . length
144148 assert . deepEqual (
@@ -150,7 +154,7 @@ function replayAction(state: ReplayState, scheduled: ScheduledAction): void {
150154 }
151155 case "finalize-streaming-call-and-cleanup" : {
152156 const scope = requireScope ( state , scopeId )
153- const result = NativeToolCallParser . finalizeStreamingToolCall ( callIds [ scopeId ] , scope )
157+ const result = NativeToolCallParser . finalizeStreamingToolCall ( streamingKey ( scopeId ) , scope )
154158 assert . equal ( result ?. type , "tool_use" )
155159 if ( result ?. type !== "tool_use" || result . name !== "read_file" ) {
156160 throw new Error ( `${ scopeId } 's streaming result was not a read_file tool use` )
@@ -161,7 +165,7 @@ function replayAction(state: ReplayState, scheduled: ScheduledAction): void {
161165 assert . equal ( result . nativeArgs ?. path , paths [ scopeId ] , `${ scopeId } 's arguments crossed request scopes` )
162166 scopeState . streamFinalizationCount += 1
163167 assert . equal (
164- NativeToolCallParser . finalizeStreamingToolCall ( callIds [ scopeId ] , scope ) ,
168+ NativeToolCallParser . finalizeStreamingToolCall ( streamingKey ( scopeId ) , scope ) ,
165169 null ,
166170 `${ scopeId } finalized its streaming call twice` ,
167171 )
@@ -174,7 +178,7 @@ function replayAction(state: ReplayState, scheduled: ScheduledAction): void {
174178 scope ,
175179 )
176180 const streamingResult = NativeToolCallParser . processStreamingChunk (
177- callIds [ scopeId ] ,
181+ streamingKey ( scopeId ) ,
178182 `late-${ scopeId } ` ,
179183 scope ,
180184 )
0 commit comments