assistant-ui icon indicating copy to clipboard operation
assistant-ui copied to clipboard

[BUG] Tool call argsText can only be appended, not updated

Open ronfogel opened this issue 2 months ago • 9 comments

After upgrading @assistant-ui/react-ai-sdk from 1.1.3 to anything above (1.1.4, 1.1.5, 1.1.6), when the model is making a tool call, I get the following error

Tool call argsText can only be appended, not updated: {...} does not start with {}

Uncaught Error: Tool call argsText can only be appended, not updated: {...} does not start with {}
    at useToolInvocations.useEffect.processMessages (useToolInvocations.ts:164:25)

I am using gemini model with streamText and minimal setup

const result = streamText({
      model: vertex('gemini-2.5-flash'),
      system: 'Some simple system prompt...',
      messages: convertToModelMessages(messages),
      tools,
    });

    return result.toUIMessageStreamResponse();

ronfogel avatar Oct 15 '25 06:10 ronfogel

Facing same error @Yonom , @AVGVSTVS96 can anyone of you help us with and unblock us ?

desusai-doordash avatar Oct 16 '25 15:10 desusai-doordash

Do we have any existing workaround / solution for this ?

Can you share any examples on how we can use generateText in chat route and send back response instead of streamText ?

desusai-doordash avatar Oct 16 '25 15:10 desusai-doordash

I guess downgrading to 1.1.3 may be a workaround. Worked when I tested it at least. 1.1.6 behaves as OP describes for me.

kabo avatar Oct 17 '25 01:10 kabo

same here...

garrylachman avatar Oct 25 '25 18:10 garrylachman

I updated all the packages (assistant-ui and vercel ai sdk) - now it works..

@ai-sdk/google-vertex 3.0.55
@ai-sdk/mcp 0.0.4
@assistant-ui/react 0.11.35
@assistant-ui/react-ai-sdk 1.1.8
@assistant-ui/react-markdown 0.11.3
ai 5.0.82
assistant-stream 0.2.38

ronfogel avatar Oct 29 '25 23:10 ronfogel

same here, downgraded @assistant-ui/react-ai-sdk from 1.1.8 to 1.1.3

natanfernandes avatar Nov 05 '25 17:11 natanfernandes

Is there a fix without downgrading?

urjitc avatar Nov 05 '25 22:11 urjitc

Can confirm, also happening for me, independent from the LLM provider (but all used through Vercel AI SDK via openAICompatible middleware)

In case it helps, here a stream which triggered the error (with the last message, therefore no expected "end" of the stream)

{"type":"start","messageId":"BCX14AsJfIyQ1466"}
{"type":"start-step"}
{"type":"text-start","id":"txt-0"}
{"type":"text-delta","id":"txt-0","delta":"Some AI answer"}
{"type":"text-delta","id":"txt-0","delta":"."}
{"type":"tool-input-start","toolCallId":"tool_0_dataforseo_google_keyword_overview_7bS4nlvMG4Yr8HfngvjK","toolName":"dat
aforseo_google_keyword_overview"}
{"type":"tool-input-delta","toolCallId":"tool_0_dataforseo_google_keyword_overview_7bS4nlvMG4Yr8HfngvjK","inputTextDelta
":"{\"location_name\":\"Germany\",\"language_code\":\"de\",\"keywords\":[\"xxx\"]}"}
{"type":"tool-input-available","toolCallId":"tool_0_dataforseo_google_keyword_overview_7bS4nlvMG4Yr8HfngvjK","toolName":
"dataforseo_google_keyword_overview","input":{"keywords":["xxx"],"location_name":"Germany","language_code":"de","include_clickstream_data":false}}

While debugging the code in useToolInvocations, the lastState.argsText always has the value of the previous tool-input-delta and the content.argsText has the value form the recent tool-input-available which (you can see also in my pasted stream example) are different. I'm not yet deeply into the format and maybe that's just a symptom of the issue, but looks like the hook compares different output results (response from a streamed delta tool-input-delta and a final tool-input-available type)

tmoennich-nf avatar Nov 10 '25 10:11 tmoennich-nf

Similar issue here. It seems that args parameters are re-ordered.

As you can see here we initially have name,surface,type then name,type,surface. There is a good chance this happens during the ser/deser.

Error: Tool call argsText can only be appended, not updated: {"name":"Test Operation Alpha","surface":150,"type":"equity"} does not start with {"name":"Test Operation Alpha","type":"equity","surface":150

A workaround is to update the inputSchema with the final order (in our case name,type,surface) fixes the issue.

kerwanp avatar Nov 19 '25 05:11 kerwanp