Skip to content

fix: support partially bound function tools - #772

Open
po-et wants to merge 1 commit into
ollama:mainfrom
po-et:fix/partial-function-tools
Open

po-et wants to merge 1 commit into
ollama:mainfrom
po-et:fix/partial-function-tools

Conversation

@po-et

@po-et po-et commented Oct 21, 2026

Copy link
Copy Markdown

Passing a function bound with functools.partial to chat(tools=[...]) raises AttributeError before the request is sent. This prevents a tool from binding an application argument, such as a tenant ID, while leaving the query for the model.

Use the wrapped function's name and docstring when the partial does not supply them, and build the schema from its bound signature. Positional arguments already supplied by the application stay out of the tool schema. Explicit metadata and __signature__ remain authoritative, and decorators on the underlying function still work.

Validation:

  • 17 new regression/control cases: 16 failures and 1 pass on the original source; all 17 pass with the change.
  • Full repository suite and doctests: 139 passed on Python 3.12.14, Pydantic 2.10.6 and HTTPX 0.28.1.
  • An independent public-API probe: 10 groups passed across sync, async and streaming calls; the same probe had 7 failures and 3 passing controls on the original source.
  • Ruff lint, repository formatting and git diff --check passed.

Tests use HTTPX fixtures and localhost HTTP servers, without model inference. Localhost was excluded from the test process's proxy configuration; the initial full run received two proxy 502 responses in existing connection-refusal tests.

Codex assisted with the implementation and tests; review and the independent API checks were also automated.

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