Skip to content

fix: sync Gemini tool-call JSON and Messages container from Python any-llm - #28

Merged
anurag-roy merged 2 commits into
mainfrom
cursor/any-llm-library-sync-ac7b
Sep 13, 2026
Merged

anurag-roy merged 2 commits into
mainfrom
cursor/any-llm-library-sync-ac7b

Conversation

@cursor

@cursor cursor Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Sync with mozilla-ai/any-llm main through c1f167b (6 new commits since 909d26e). One PR for the applicable library changes.

Ported

  • #1330: reject malformed Gemini tool-call arguments. Serialized arguments that are not valid JSON now raise InvalidRequestError instead of being wrapped as { arguments: "..." }. Empty strings and already-parsed objects still become {} / the object. Tool schemas with JSON Schema type unions ({"type": ["string", "null"]}) already go through parametersJsonSchema in this port, so the Python OpenAPI Schema.type enum path is not used. Vertex AI inherits the same conversion.
  • #1329: add Messages container for continuing a previous top-level Anthropic code-execution container. Native Anthropic-family adapters forward it. The completions bridge rejects it with UnsupportedOperationError. Meta and Otari reject it with UnsupportedParameterError (Otari SDK 0.3.0 drops the field; Meta does not document it).

Skipped (not applicable)

  • #1353: native xAI protobuf finish-reason mapping. This port's xAI is an OpenAI-compatible registry row and already passes finish reasons through.
  • #1326: native xAI protobuf tool-call ID reconstruction. OpenAI-compatible xAI already preserves tool-call IDs.
  • #1355: Python docstring default corrections. listBatches already takes optional limit.
  • #1363: Python pre-commit pin bump.

Tracked source SHA is now c1f167bc0d24d6321e2e02a61cf4363ccb6c3246. oxfmt and oxlint were run after the changes.

Open in Web View Automation 

Note

Medium Risk
Gemini now throws on malformed tool-call JSON (behavior change for callers that relied on silent wrapping), and Messages container is a new request surface with provider-specific accept/reject rules.

Overview
Syncs the TypeScript port with Python any-llm at 2388f59 (patch changeset).

Gemini tool-call arguments: Serialized assistant tool function.arguments that are not valid JSON (strings, buffers) now fail at request build time with InvalidRequestError and a message naming the function, instead of silently wrapping bad input as { arguments: "..." }. Empty encoded args still become {}; valid JSON and plain objects are unchanged. Provider name is threaded through message/batch conversion for error attribution.

Messages container: Adds optional container on MessagesParams for continuing a prior Anthropic top-level code-execution container. Native Anthropic forwards it on messages.create. The default completions-backed messages() path rejects it with UnsupportedOperationError; Meta and Otari reject with UnsupportedParameterError. Docs and parity manifest/commit pins are updated; tests cover forwarding and rejection paths.

Reviewed by Cursor Bugbot for commit 81b4980. Bugbot is set up for automated code reviews on this repo. Configure here.

…y-llm

Port mozilla-ai/any-llm #1330 and #1329: reject malformed Gemini tool-call
arguments as InvalidRequestError, and add Messages container continuity for
native Anthropic (rejected on the completions bridge, Meta, and Otari).

Co-authored-by: Anurag Roy <anuragroy@duck.com>
@vercel

vercel Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
any-llm-ts Ready Ready Preview Sep 5, 2026 3:33am UTC

mozilla-ai/any-llm #1371 pins the Python Anthropic SDK below 1.x. That
does not apply here: @anthropic-ai/sdk is still 0.x and already cannot
resolve 1.x. Update the tracked source SHA on the existing sync PR.

Co-authored-by: Anurag Roy <anuragroy@duck.com>

This branch was successfully deployed

1 active deployment
Preview — 81b49803 Deployed Sep 5, 2026 by vercel[bot]
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.

2 participants