Skip to content

Commit 4abfbfd

Browse files
jherrclaude
andcommitted
fix: resolve approval lookup after RUN_FINISHED and update smoke test state names
Fall back to toolCallToMessage map when resolving approval requests after RUN_FINISHED clears activeMessageIds. Update smoke test to use current tool call state names (input-complete, approval-responded, input-streaming). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent da5bfc3 commit 4abfbfd

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

packages/typescript/ai/src/activities/chat/stream/processor.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,11 +1142,15 @@ export class StreamProcessor {
11421142
approval: { id: string; needsApproval: boolean }
11431143
}
11441144

1145-
// Update the tool call part with approval state
1146-
if (messageId) {
1145+
// Resolve the message containing this tool call. After RUN_FINISHED,
1146+
// activeMessageIds is cleared, so fall back to the toolCallToMessage map
1147+
// which is populated during TOOL_CALL_START and preserved across finalize.
1148+
const resolvedMessageId =
1149+
messageId ?? this.toolCallToMessage.get(toolCallId)
1150+
if (resolvedMessageId) {
11471151
this.messages = updateToolCallApproval(
11481152
this.messages,
1149-
messageId,
1153+
resolvedMessageId,
11501154
toolCallId,
11511155
approval.id,
11521156
)

packages/typescript/smoke-tests/e2e/src/routes/tools-test.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ function ToolsTestPage() {
186186
)
187187
const pendingCalls = allToolCalls.filter(
188188
(tc) =>
189-
tc.state !== 'complete' &&
190-
tc.state !== 'output-available' &&
189+
tc.state !== 'input-complete' &&
190+
tc.state !== 'approval-responded' &&
191191
tc.output === undefined &&
192192
!resultIds.has(tc.id),
193193
)
@@ -509,9 +509,10 @@ function ToolsTestPage() {
509509
padding: '2px 6px',
510510
borderRadius: '3px',
511511
backgroundColor:
512-
tc.state === 'complete'
512+
tc.state === 'input-complete' ||
513+
tc.state === 'approval-responded'
513514
? '#28a745'
514-
: tc.state === 'streaming-arguments'
515+
: tc.state === 'input-streaming'
515516
? '#ffc107'
516517
: tc.state === 'approval-requested'
517518
? '#17a2b8'
@@ -572,8 +573,8 @@ function ToolsTestPage() {
572573
data-complete-tool-count={
573574
toolCalls.filter(
574575
(tc) =>
575-
tc.state === 'complete' ||
576-
tc.state === 'output-available' ||
576+
tc.state === 'input-complete' ||
577+
tc.state === 'approval-responded' ||
577578
tc.output !== undefined ||
578579
toolResultIds.has(tc.id),
579580
).length

0 commit comments

Comments
 (0)