From e91393f9bd5a8c0eb1c6fd51c0856ac5bee61d62 Mon Sep 17 00:00:00 2001 From: anish Date: Fri, 19 Jun 2026 21:46:54 +0000 Subject: [PATCH] fix: handle missing tool_call.id in runTools for providers Some providers do not populate the `tool_call.id` field when returning tool calls, or may set it to an empty string. When the SDK's `AbstractChatCompletionRunner._runTools()` method constructs tool result messages to send back to the API, it uses this empty or missing `tool_call_id`, which causes the API to reject the request with a 400 status code. Signed-off-by: anish --- src/lib/AbstractChatCompletionRunner.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/AbstractChatCompletionRunner.ts b/src/lib/AbstractChatCompletionRunner.ts index 815d1927d..626620baa 100644 --- a/src/lib/AbstractChatCompletionRunner.ts +++ b/src/lib/AbstractChatCompletionRunner.ts @@ -341,8 +341,9 @@ export class AbstractChatCompletionRunner< for (const tool_call of message.tool_calls) { if (tool_call.type !== 'function') continue; - const tool_call_id = tool_call.id; const { name, arguments: args } = tool_call.function; + // Some LLM providers may not populate tool_call.id; use function name as fallback + const tool_call_id = tool_call.id || name; const fn = functionsByName[name]; if (!fn) {