Skip to content

fix(examples): handle numeric strings in async arithmetic tools - #761

Open
Mucheen wants to merge 1 commit into
ollama:mainfrom
Mucheen:codex/coerce-async-tool-numbers
Open

Mucheen wants to merge 1 commit into
ollama:mainfrom
Mucheen:codex/coerce-async-tool-numbers

Conversation

@Mucheen

@Mucheen Mucheen commented Oct 13, 2026

Copy link
Copy Markdown

The asynchronous tool example adds raw tool arguments directly, so {"a": "30", "b": "12"} produces 3012; subtraction raises TypeError. Convert both arguments to integers, matching the synchronous example's existing behavior from #443.

Add an offline regression that executes the real example's main() with scripted model responses and checks the complete conversation passed to the final model call. It covers string and integer inputs for both operations. Only the model client is mocked.

This is a source-discovered follow-up, not a fix for an existing open issue. On unchanged main at 8785556, the new tests produce two expected failures and two passes; with the fix all four pass.

Validation on Python 3.12.14:

  • NO_PROXY=localhost,127.0.0.1,::1 no_proxy=localhost,127.0.0.1,::1 uv run --with pytest --with pytest-httpserver pytest ollama tests -v: 124 passed, including doctests. Localhost bypass is needed for this machine's proxy setup.
  • uvx ruff format --check: 47 files already formatted.
  • uvx ruff check: all checks passed.
  • uv lock --check passes; uv export exactly matches committed requirements.txt.
  • git diff --check passes.

The attempted uvx hatch test tests/test_async_tools_example.py -vv could not install its tooling because the download of the uv wheel timed out. The CI matrix command uvx hatch test -acp has not run locally; the test and lint commands above ran successfully. No inference, model download, or API credentials were used. OpenAI Codex assisted with the patch and tests.

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