Skip to content

Fix/add id to toolcall - #712

Open
SaiDevaHarshaR wants to merge 5 commits into
ollama:mainfrom
SaiDevaHarshaR:fix/add-id-to-toolcall
Open

Fix/add id to toolcall#712
SaiDevaHarshaR wants to merge 5 commits into
ollama:mainfrom
SaiDevaHarshaR:fix/add-id-to-toolcall

Conversation

@SaiDevaHarshaR

Copy link
Copy Markdown

What this fixes

Fixes #667 — ToolCall is missing id field required by OpenAI API spec.
When using ollama-python responses with OpenAI-compatible tools,
tool_call_id is missing causing errors.

Change

Added id: Optional[str] = None to Message.ToolCall:

class ToolCall(SubscriptableBaseModel):
    id: Optional[str] = None  # added
    function: Function

Why Optional

Making it optional preserves backward compatibility — existing code
that creates ToolCall without id continues to work.

Testing

# With id
tc = Message.ToolCall(id="call_abc123", function=...)
print(tc.id)  # "call_abc123"

# Without id (backward compatible)
tc = Message.ToolCall(function=...)
print(tc.id)  # None

Closes #667

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id in ToolCall missing

1 participant