mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
3deeb74ca7
* Re-inject tool call names on OpenAI-compatible stream desync Some OpenAI-compatible gateways emit tool_call chunks the AI SDK rejects or ignores (non-standard `type` values, tool calls outside choices[0]). The chunk normalizer had already recorded the tool call id, so later nameless continuation chunks were forwarded with an injected id and the SDK threw "Expected 'function.name' to be a string." on what it saw as a brand-new tool call. Remember each tool call's function name when its id is assigned and re-inject it (plus type "function") into continuation chunks so every forwarded chunk is self-describing, and coerce non-standard tool_call type strings to "function" so the naming chunk itself is not dropped by schema validation. Fixes #1954. Co-authored-by: Cursor <cursoragent@cursor.com> * Preserve argument prefixes from SDK-invisible tool call chunks Codex review on #1966 flagged that when the chunk establishing a tool call is invisible to the AI SDK (which only reads choices[0]), any argument fragment it carried was lost: the recovery path re-injected the name but forwarded only the suffix arguments, producing truncated tool input. Track the full concatenation of argument fragments per tool call key and which keys have been forwarded at choices array position 0. The first chunk forwarded where the SDK can see it now carries the full accumulated arguments; already-visible tool calls keep streaming incremental fragments as before. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>