litellm/tests/unit/llms/ollama
Mateo Wang 9c4217d931
fix(ollama_chat): split a replayed tool call whose arguments glue JSON objects (#55781)
* fix(ollama_chat): split a replayed tool call whose arguments glue JSON objects

Before #49183, ollama_chat streaming gave every parallel tool call index 0, so clients
like Codex merged them into one call whose arguments hold several JSON objects and kept
it in the session history. Replaying that history answered 500 and, since #49183, 400 on
every later turn, so the session stayed stuck after upgrading.

The replay now splits such arguments into one Ollama tool call per object, gives each
extra call an id derived from the original, and copies the matching tool result to every
derived id, the same way the Anthropic and Bedrock paths already do. Identical repeats
collapse to one call, and non-object or trailing data still answers 400.

The split id helpers in factory.py become public so the Ollama transform can reuse them.

Based on the direction of #54358 by @elinacse.

* test(ollama_chat): cover braces inside a string value and a glued call outside an assistant turn

* fix(ollama_chat): answer 400 for a glued tool call without an id

* fix(ollama_chat): keep a glued call without an id as one call when its objects are all the same

* fix(ollama_chat): forward a tool id that is not a string instead of failing with a 500

The split-id lookups added for glued tool calls used the id as a dict key, so a tool result whose
tool_call_id is a list, or a glued call whose id is a list, raised TypeError and answered 500. They now
take only string ids, so those requests reach Ollama or answer 400 as they did before this change
2026-12-03 20:27:21 +00:00
..
__init__.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_ollama_chat_transformation.py fix(ollama_chat): split a replayed tool call whose arguments glue JSON objects (#55781) 2026-12-03 20:27:21 +00:00
test_ollama_completion_transformation.py fix(mcp)!: answer 400 for a hosted MCP tool a translated route cannot run, drop it under drop_params (#48931) 2026-11-02 13:13:03 -08:00
test_ollama_embedding.py refactor(typing): clear 21 basedpyright Any errors across 15 files (#55751) 2026-12-02 19:50:42 -08:00
test_ollama_model_info.py fix(ollama): send model-info lookups to the call's api_base with its key and retry failed ones (#53830) 2026-11-24 08:51:25 -08:00
test_ollama_text_completion.py test: migrate local_testing SDK and provider tests out of build_and_test (#45760) 2026-10-10 23:14:25 +00:00