Fix: pass tool_call_id through to watsonx API

watsonx requires tool_call_id on role=tool messages.
Added field to ChatMessage model and passthrough in transformer.
This commit is contained in:
2026-02-23 18:46:46 +00:00
parent 592b34cff0
commit c6232d262d
2 changed files with 5 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ class ChatMessage(BaseModel):
name: Optional[str] = None
function_call: Optional[Dict[str, Any]] = None
tool_calls: Optional[List[Dict[str, Any]]] = None
tool_call_id: Optional[str] = None
class FunctionCall(BaseModel):
@@ -85,6 +86,7 @@ class ChatCompletionChunkDelta(BaseModel):
content: Optional[Union[str, List[Dict[str, Any]]]] = None
function_call: Optional[Dict[str, Any]] = None
tool_calls: Optional[List[Dict[str, Any]]] = None
tool_call_id: Optional[str] = None
class ChatCompletionChunkChoice(BaseModel):

View File

@@ -47,6 +47,9 @@ def transform_messages_to_watsonx(messages: List[ChatMessage]) -> List[Dict[str,
if msg.function_call:
watsonx_msg["function_call"] = msg.function_call
if msg.tool_call_id:
watsonx_msg["tool_call_id"] = msg.tool_call_id
watsonx_messages.append(watsonx_msg)
return watsonx_messages