Skip to content

types: preserve tool call function indexes - #760

Open
er-s-an wants to merge 1 commit into
ollama:mainfrom
er-s-an:fix/tool-call-function-index-20261012
Open

er-s-an wants to merge 1 commit into
ollama:mainfrom
er-s-an:fix/tool-call-function-index-20261012

Conversation

@er-s-an

@er-s-an er-s-an commented Oct 12, 2026

Copy link
Copy Markdown

Ollama's native tool parser assigns an incrementing index to each tool-call function. Message.ToolCall.Function currently drops that field when parsing native chat responses.

Add index: Optional[int] = None so callers can read and preserve this server-provided metadata. Responses without an index still parse, and exclude-none serialization keeps their existing shape.

Seven regression cases cover zero and nonzero indexes, attribute and mapping access, response/history serialization, old payloads without an index, and both sync/async chat with streaming on and off.

Validation on Python 3.12.14:

  • New regressions on unchanged main: 6 failed, 1 compatibility control passed.
  • Full suite and doctests: pytest ollama tests -q -> 127 passed.
  • Ruff lint/format checks and git diff --check passed.
  • Wheel/source builds, lock consistency, and requirements export checks passed.

The transport tests use a local mock HTTP server. No live model inference or broader Python/OS matrix was run.

Prepared with AI assistance and independently reviewed by a second AI agent. No human pre-review is claimed.

@er-s-an
er-s-an marked this pull request as ready for review October 12, 2026 12:33

This branch has not been deployed

No deployments
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.

1 participant