Skip to content

id in ToolCall missing #667

Description

@randre70

The id field in the tool_call is missing. The raw response (hook) contains the id (see below, "id": "call_p7o2gz50").
But the ToolCall class doesn't have this field nor is it in model_extra.

{
  "model": "...",
  "created_at": "2026-05-18T...",
  "message": {
    "role": "assistant",
    "content": " ",
    "tool_calls": [
      {
        "id": "call_p7o2gz50",
        "function": {
          "index": 0,
          "name": "test_function",
          "arguments": {
            "param1": "test1",
            "param2": 123
          }
        }
      }
    ]
  },
  "done": true,
  "done_reason": "stop",
  ...
}

I have to use a hook to extract the id from the raw response and keep it in a list of the same size as the response.message.tool_calls list.

I suggest the following patch:

diff --git a/ollama/_types.py b/ollama/_types.py
index 96529d6..fdc00d2 100644
--- a/ollama/_types.py
+++ b/ollama/_types.py
@@ -334,6 +334,8 @@ class Message(SubscriptableBaseModel):
     """
     Model tool calls.
     """
+    id: Optional[str] = None
+    'ID of the tool call.'
 
     class Function(SubscriptableBaseModel):
       """

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions