Skip to content
Source
Sign inSign up
TanStack/ai

fix(ai-acp): send tool-call input before TOOL_CALL_END #2273

Mergedcanblmz1(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/2273/headmerged by AlemTuzlak View on GitHub

Showing 3 changed files with 80 additions and 36 deletions (loading 1).

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/acp-tool-call-args-before-end.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/ai-acp': patch
+---
+​
+Keep a tool call opened without `rawInput` open until its input arrives, so the later `tool_call_update` sends `TOOL_CALL_ARGS` before `TOOL_CALL_END`. It was sent after the call had ended, and the UI appended it to the finalized arguments as doubled JSON. A call that resolves or is interrupted without input is closed with its title before its result.
75 additions and 36 deletionspackages/ai-acp/src/stream/translate.tsModified
View file
@@ -123,6 +123,13 @@
let runStarted = false
const unresolvedToolCalls = new Set<string>()
const knownToolCalls = new Set<string>()
+ // Calls started without `rawInput`: their ARGS + END wait for the
+ // tool_call_update that carries it, or for the call to resolve, so no
+ // TOOL_CALL_ARGS follows TOOL_CALL_END.
+ const awaitingInput = new Map<
+ string,
+ { toolCallName: string; title?: string }
+ >()
​
let textMessageId: string | null = null
let textContent = ''
@@ -174,6 +181,7 @@
​
function* synthesizeUnresolvedResults(): Generator<AdapterYieldChunk> {
for (const toolCallId of unresolvedToolCalls) {
+ yield* closeAwaitingToolCall({ toolCallId })
yield {
type: EventType.TOOL_CALL_RESULT,