Skip to content

Commit 227de78

Browse files
committed
fix(scripts): adapt parser-scoping model check to compound streaming keys
The shared-SDK error-handle PR keys streaming tool-call state by the compound id::name key and emits the tool name on tool_call_end. Update the scoping model-check harness to construct the same compound keys and expect the name field, preserving all 924 schedules, invariants, and landmarks.
1 parent 8f7a6aa commit 227de78

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎scripts/check-native-tool-call-parser-scoping.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
4852
const expectedActions = new Set<LocalAction>(localActions)
4953
const reachedActions = new Set<LocalAction>()
5054
const 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

Comments
 (0)