Skip to content

fix(ollama_chat): backport streamed tool call indices to lts/1.108.x (#49183) - #50718

Merged
mateo-berri merged 8 commits into
BerriAI:lts/1.108.xfrom
zoveki:litellm_backport_49183_lts_1_108_x
Nov 9, 2026
Merged

mateo-berri merged 8 commits into
BerriAI:lts/1.108.xfrom
zoveki:litellm_backport_49183_lts_1_108_x

Conversation

@zoveki

@zoveki zoveki commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

This brings #49183 to the 1.108 LTS line. When an ollama_chat/ model streams several tool calls at once, each now gets its own index, so OpenCode runs every call. Replaying a glued call answers 400 naming it instead of 500, and empty arguments now work

Original

TLDR

Backport of #49183 to lts/1.108.x

Problem this solves:

  • ollama_chat/ streaming sets index: 0 on every tool call delta
  • Clients merge parallel calls into call 0, or drop the later ones
  • OpenCode runs only the first of two parallel reads
  • Sending back a merged call, or one with empty arguments, answers HTTP 500

How it solves it:

  • One counter numbers tool calls across the whole stream
  • Replayed arguments use the shared repair parser, and ones still not an object answer 400 naming the call
  • The parser's repair warning keeps its preview unless turn_off_message_logging is on
  • Non-streaming requests parse replayed arguments the same way, and single-call streams are unchanged

Backport checklist

  • All 7 commits of fix(ollama_chat): give each streamed tool call its own index #49183 are picked, 3 applied clean and 4 adapted to the line
  • Merged the line's newer tip b8150535251 as 2fd636e6103, keeping both imports in its one conflict
  • The importer scan finds no dropped name used on the line
  • At 2fd636e6103 the picks' two test files pass (302/302), and so do 6,911 other tests in files that reach the change
  • No dependency bump (no known issue in the lock has a fix main takes) and no subpackage bump (enterprise/ and litellm-proxy-extras/ are unchanged)
  • Gauntlet-mini: SURVIVED, 5/5 lenses, 0 confirmed (all fixed) on runs bc6b95931ab0, 840a315cb670, 7653bda50a6a, 408326a3abf1, 79de5303c465 and 61c0db3b0a08, which reviewed 9dd965188fb, 8421785a043, 23603928924, 2280aa224b9, d9011b1593f and 2fd636e6103
The 7 picks, adaptations, the confirmed finding, and rejected findings
  • df6126edaa0 (one tool call counter per stream) applied clean as a547ed0a94b

  • 84154df9e98 (400 for replayed arguments that are not JSON) applied clean as 9dd965188fb

  • 0ae806cce40 (shared repair parser for replayed arguments) adapted as 8f84442124d, see below

  • e6044318cc2 ({} for "null" arguments, no argument text in the repair warning) adapted as 8421785a043, see below

  • 0f7003a2aeb (no argument text in a rejected replay's error chain) applied clean as 23603928924

  • 5ef6d62cca7 (repair warning preview kept unless message logging is off) adapted as 2280aa224b9, see below

  • 1f71ed377f4 (more repair warning tests) adapted as d9011b1593f, see below

  • 8f84442124d imports parse_tool_call_arguments from common_utils, its home on the line. One test expects no tool call id, since fix(ollama): forward assistant tool call ids in ollama_chat requests #49278 is not on the line

  • 8421785a043 and 2280aa224b9 make their repair warning changes in common_utils, the warning's home on the line, and they and d9011b1593f put their tests in that module's test file

  • Confirmed by run 8d1a27df4e46 on 8f84442124d. Replayed "null" arguments went from 200 to 400. fix(ollama_chat): give each streamed tool call its own index #49183 fixed it in e6044318cc2, picked as 8421785a043, which run 840a315cb670 reviewed

  • Strongest dissent, rejected. One tool call streamed as string fragments across chunks would get two indices, but Ollama 0.40.14 sends each call whole, and fix(ollama_chat): give each streamed tool call its own index #49183 on main does the same

  • Rejected. A mixed-provider group with retries, or fallback_on_unsupported_params: false, does not retry the 400, which is the intended answer, and default fallbacks still fire

  • Rejected. Style nits and a missing 201-character case in the picked tests mirror fix(ollama_chat): give each streamed tool call its own index #49183

  • Strongest dissent on 8421785a043, rejected. Arguments the parser cannot repair still reach a WARNING log in full through its error text, which the line tip and main already do

  • Rejected. A no-argument streamed tool call that Ollama sends without an id is dropped when the stream is rebuilt, the same on the line tip and main, and Ollama 0.40.14 sends ids

  • Rejected. Deeply nested array arguments raise a 500 through RecursionError, the same on the line tip

  • Strongest dissent on 23603928924, rejected. The parse error stays on the 400's __context__, so code that reads it directly could still see the arguments, but nothing on the line does, and tracebacks, logging and Sentry skip it

  • Rejected. The [] case's traceback check cannot fail, but the case still catches a parsed or {} rewrite, the same as fix(ollama_chat): give each streamed tool call its own index #49183

  • Strongest dissent on 2280aa224b9, rejected. A request that turns message logging off only for itself, per key or through compaction, still gets the 200-character preview, but the line's release logs it under every setting and fix(ollama_chat): give each streamed tool call its own index #49183 does the same

  • Rejected. A secret that crosses character 200 is cut before the secret filter sees it, the same as the line's release

  • Rejected. No test pins a short argument string being logged in full, the same as fix(ollama_chat): give each streamed tool call its own index #49183

  • Run 61c0db3b0a08 on the merge 2fd636e6103 found nothing the merge causes. The line's new code in common_utils and factory never calls what the picks changed, and every side note it raised (a history tool call with no type answering 500, a streamed no-argument call with no id, the per-request logging flag) behaves the same on the line tip

User Flow

Before: an OpenCode user on an Ollama model behind the proxy asks for two files at once and only the first is read

  1. They point OpenCode's @ai-sdk/openai-compatible provider at https://litellm-domain/v1 with an ollama_chat/ model
  2. They ask it to read a.rs and b.rs, both tool calls at once
  3. POST https://litellm-domain/v1/chat/completions streams both tool calls at "index": 0
  4. OpenCode shows one Read a.rs and never reads b.rs (the OpenAI SDK glues both into one call with arguments {"path": "a.rs"}{"path": "b.rs"})
  5. Sending that glued call back on the next turn answers HTTP 500 litellm.APIConnectionError: Extra data

After: the same request comes back as two tool calls and OpenCode reads both files

  1. Same setup and prompt as above
  2. POST https://litellm-domain/v1/chat/completions streams the tool calls at "index": 0 and "index": 1
  3. OpenCode shows Read a.rs and Read b.rs
  4. Sending both calls and results back returns 200, and an old glued call in the history answers HTTP 400 naming its id

Relevant issues

The fix for #33678 on lts/1.108.x. #49183, its main PR, merges first

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Screenshots / Proof of Fix

Ollama 0.40.14 serves qwen3:0.6b. Each leg runs 2 workers with its own Redis and no --reload. Each OpenCode trial types Read the files a.rs and b.rs. Call the read tool once for each file, both calls at once.

qa_config_<leg>.yaml (only the Redis port differs)
model_list:
- model_name: anthropic-haiku-4-5
  litellm_params:
    model: anthropic/claude-haiku-4-5
    api_key: os.environ/ANTHROPIC_API_KEY
- model_name: anthropic-sonnet-4-5
  litellm_params:
    model: anthropic/claude-sonnet-4-5
    api_key: os.environ/ANTHROPIC_API_KEY
- model_name: anthropic-opus-4-5
  litellm_params:
    model: anthropic/claude-opus-4-5
    api_key: os.environ/ANTHROPIC_API_KEY
- model_name: anthropic-sonnet-4-6
  litellm_params:
    model: anthropic/claude-sonnet-4-6
    api_key: os.environ/ANTHROPIC_API_KEY
- model_name: anthropic-opus-4-6
  litellm_params:
    model: anthropic/claude-opus-4-6
    api_key: os.environ/ANTHROPIC_API_KEY
- model_name: anthropic-opus-4-7
  litellm_params:
    model: anthropic/claude-opus-4-7
    api_key: os.environ/ANTHROPIC_API_KEY
- model_name: anthropic-opus-4-8
  litellm_params:
    model: anthropic/claude-opus-4-8
    api_key: os.environ/ANTHROPIC_API_KEY
- model_name: anthropic-sonnet-5
  litellm_params:
    model: anthropic/claude-sonnet-5
    api_key: os.environ/ANTHROPIC_API_KEY
- model_name: voyage-4-large
  litellm_params:
    model: voyage/voyage-4-large
    api_key: os.environ/VOYAGE_API_KEY
- model_name: bedrock-invoke-haiku-4-5
  litellm_params:
    model: bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0
    aws_region_name: us-east-1
- model_name: bedrock-invoke-sonnet-4-5
  litellm_params:
    model: bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0
    aws_region_name: us-east-1
- model_name: bedrock-invoke-opus-4-5
  litellm_params:
    model: bedrock/us.anthropic.claude-opus-4-5-20251101-v1:0
    aws_region_name: us-east-1
- model_name: bedrock-invoke-sonnet-4-6
  litellm_params:
    model: bedrock/us.anthropic.claude-sonnet-4-6
    aws_region_name: us-east-1
- model_name: bedrock-invoke-opus-4-6
  litellm_params:
    model: bedrock/us.anthropic.claude-opus-4-6-v1
    aws_region_name: us-east-1
- model_name: bedrock-invoke-opus-4-7
  litellm_params:
    model: bedrock/global.anthropic.claude-opus-4-7
    aws_region_name: us-east-1
- model_name: bedrock-invoke-opus-4-8
  litellm_params:
    model: bedrock/global.anthropic.claude-opus-4-8
    aws_region_name: us-east-1
- model_name: bedrock-converse-haiku-4-5
  litellm_params:
    model: bedrock/converse/us.anthropic.claude-haiku-4-5-20251001-v1:0
    aws_region_name: us-east-1
- model_name: bedrock-converse-sonnet-4-5
  litellm_params:
    model: bedrock/converse/us.anthropic.claude-sonnet-4-5-20250929-v1:0
    aws_region_name: us-east-1
- model_name: bedrock-converse-opus-4-5
  litellm_params:
    model: bedrock/converse/us.anthropic.claude-opus-4-5-20251101-v1:0
    aws_region_name: us-east-1
- model_name: bedrock-converse-sonnet-4-6
  litellm_params:
    model: bedrock/converse/us.anthropic.claude-sonnet-4-6
    aws_region_name: us-east-1
- model_name: bedrock-converse-opus-4-6
  litellm_params:
    model: bedrock/converse/us.anthropic.claude-opus-4-6-v1
    aws_region_name: us-east-1
- model_name: bedrock-converse-opus-4-7
  litellm_params:
    model: bedrock/converse/global.anthropic.claude-opus-4-7
    aws_region_name: us-east-1
- model_name: bedrock-converse-opus-4-8
  litellm_params:
    model: bedrock/converse/global.anthropic.claude-opus-4-8
    aws_region_name: us-east-1
- model_name: vertex-haiku-4-5
  litellm_params:
    model: vertex_ai/claude-haiku-4-5@20251001
    vertex_project: os.environ/VERTEXAI_PROJECT
    vertex_location: global
- model_name: vertex-sonnet-4-5
  litellm_params:
    model: vertex_ai/claude-sonnet-4-5@20250929
    vertex_project: os.environ/VERTEXAI_PROJECT
    vertex_location: global
- model_name: vertex-opus-4-5
  litellm_params:
    model: vertex_ai/claude-opus-4-5@20251101
    vertex_project: os.environ/VERTEXAI_PROJECT
    vertex_location: global
- model_name: vertex-sonnet-4-6
  litellm_params:
    model: vertex_ai/claude-sonnet-4-6
    vertex_project: os.environ/VERTEXAI_PROJECT
    vertex_location: global
- model_name: vertex-opus-4-6
  litellm_params:
    model: vertex_ai/claude-opus-4-6
    vertex_project: os.environ/VERTEXAI_PROJECT
    vertex_location: global
- model_name: vertex-opus-4-7
  litellm_params:
    model: vertex_ai/claude-opus-4-7
    vertex_project: os.environ/VERTEXAI_PROJECT
    vertex_location: global
- model_name: vertex-opus-4-8
  litellm_params:
    model: vertex_ai/claude-opus-4-8
    vertex_project: os.environ/VERTEXAI_PROJECT
    vertex_location: global
- model_name: gemini-claude-code
  litellm_params:
    model: vertex_ai/gemini-2.5-pro
    vertex_project: os.environ/VERTEXAI_PROJECT
    vertex_location: global
    vertex_credentials: os.environ/GEMINI_CLAUDE_CODE_VERTEX_CREDENTIALS
    extra_body:
      labels:
        workload: claude-code
        source: litellm
        environment: internal
        reconciliation_group: claude-code-gemini
- model_name: azure-haiku-4-5
  litellm_params:
    model: azure_ai/claude-haiku-4-5
    api_base: os.environ/AZURE_AI_API_BASE
    api_key: os.environ/AZURE_AI_API_KEY
- model_name: azure-sonnet-4-5
  litellm_params:
    model: azure_ai/claude-sonnet-4-5
    api_base: os.environ/AZURE_AI_API_BASE
    api_key: os.environ/AZURE_AI_API_KEY
- model_name: azure-opus-4-5
  litellm_params:
    model: azure_ai/claude-opus-4-5
    api_base: os.environ/AZURE_AI_API_BASE
    api_key: os.environ/AZURE_AI_API_KEY
- model_name: azure-sonnet-4-6
  litellm_params:
    model: azure_ai/claude-sonnet-4-6
    api_base: os.environ/AZURE_AI_API_BASE
    api_key: os.environ/AZURE_AI_API_KEY
- model_name: azure-opus-4-6
  litellm_params:
    model: azure_ai/claude-opus-4-6
    api_base: os.environ/AZURE_AI_API_BASE
    api_key: os.environ/AZURE_AI_API_KEY
- model_name: azure-opus-4-7
  litellm_params:
    model: azure_ai/claude-opus-4-7
    api_base: os.environ/AZURE_AI_API_BASE
    api_key: os.environ/AZURE_AI_API_KEY
- model_name: azure-opus-4-8
  litellm_params:
    model: azure_ai/claude-opus-4-8
    api_base: os.environ/AZURE_AI_API_BASE
    api_key: os.environ/AZURE_AI_API_KEY
- model_name: gpt-5.5
  litellm_params:
    model: openai/gpt-5.5
    api_key: os.environ/OPENAI_API_KEY
- model_name: gpt-4o-mini
  litellm_params:
    model: openai/gpt-4o-mini
    api_key: os.environ/OPENAI_API_KEY
- model_name: ollama-qwen3
  litellm_params:
    model: ollama_chat/qwen3:0.6b
    api_base: http://127.0.0.1:<ollama port>
- model_name: ollama-qwen3-opencode
  litellm_params:
    model: ollama_chat/qwen3:0.6b
    api_base: http://127.0.0.1:<ollama port>
    num_ctx: 32768
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  coordination_redis:
    host: 127.0.0.1
    port: <redis port>
sandbox_tools:
- sandbox_tool_name: e2b_sandbox
  litellm_params:
    sandbox_provider: e2b
    api_key: os.environ/E2B_API_KEY
litellm_settings:
  drop_params: true
  code_interpreter_interception_params:
    enabled: true
    sandbox_tool_name: e2b_sandbox
  callbacks:
  - code_interpreter_interception
router_settings:
  redis_host: 127.0.0.1
  redis_port: <redis port>
opencode.json (OpenCode 1.19.5 TUI under tmux, isolated HOME)
{
  "$schema": "https://opencode.ai/config.json",
  "autoupdate": false,
  "share": "disabled",
  "provider": {
    "litellm": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LiteLLM proxy",
      "options": {
        "baseURL": "http://127.0.0.1:<proxy port>/v1",
        "apiKey": "{env:LITELLM_MASTER_KEY}"
      },
      "models": {
        "ollama-qwen3-opencode": {
          "name": "qwen3:0.6b on Ollama via LiteLLM",
          "tool_call": true,
          "limit": { "context": 32768, "output": 4096 }
        }
      }
    }
  },
  "model": "litellm/ollama-qwen3-opencode"
}
qa_client.py (OpenAI Python SDK 3.46.0 and Anthropic Python SDK 2.6.0, three runs per case)
import json
import os
import sys

import anthropic
import openai

BASE = os.environ["BASE"]
KEY = os.environ["KEY"]
MODEL = os.environ.get("MODEL", "ollama-qwen3")
PROMPT = "Read the files a.rs and b.rs. Call read_file once for each file, both calls at once."
SCHEMA = {"type": "object", "properties": {"path": {"type": "string"}}, "required": ["path"]}

def verdict(arguments):
    try:
        json.loads(arguments)
        return "valid JSON"
    except ValueError as exc:
        return f"NOT JSON ({exc})"

def chat():
    client = openai.OpenAI(base_url=f"{BASE}/v1", api_key=KEY, max_retries=0)
    tools = [{"type": "function", "function": {"name": "read_file", "description": "Read one file from disk.", "parameters": SCHEMA}}]
    messages = [{"role": "user", "content": PROMPT}]
    with client.chat.completions.stream(model=MODEL, messages=messages, tools=tools) as stream:
        for event in stream:
            if event.type != "chunk":
                continue
            for choice in event.chunk.choices:
                for tc in choice.delta.tool_calls or []:
                    print(f"turn 1 delta: index={tc.index} id={tc.id} name={tc.function.name} arguments={tc.function.arguments}")
        final = stream.get_final_completion().choices[0].message
    print(f"turn 1 assembled by the SDK: {len(final.tool_calls or [])} tool call(s)")
    for tc in final.tool_calls or []:
        print(f"  name={tc.function.name} arguments={tc.function.arguments} -> {verdict(tc.function.arguments)}")
    if not final.tool_calls:
        return
    history = messages + [final.model_dump(exclude_none=True)] + [
        {"role": "tool", "tool_call_id": tc.id, "content": "fn main() {}"} for tc in final.tool_calls
    ]
    try:
        with client.chat.completions.stream(model=MODEL, messages=history, tools=tools) as stream:
            text = "".join(
                event.delta for event in stream if event.type == "content.delta"
            )
        print(f"turn 2 (tool results sent back): 200 OK, reply {text[:80]!r}")
    except openai.APIStatusError as exc:
        print(f"turn 2 (tool results sent back): HTTP {exc.status_code} {str(exc.message)[:300]}")

def responses():
    client = openai.OpenAI(base_url=f"{BASE}/v1", api_key=KEY, max_retries=0)
    tools = [{"type": "function", "name": "read_file", "description": "Read one file from disk.", "parameters": SCHEMA}]
    with client.responses.stream(model=MODEL, input=PROMPT, tools=tools) as stream:
        for event in stream:
            if event.type == "response.output_item.added" and event.item.type == "function_call":
                print(f"output_item.added: output_index={event.output_index} call_id={event.item.call_id} name={event.item.name}")
        final = stream.get_final_response()
    calls = [item for item in final.output if item.type == "function_call"]
    print(f"assembled by the SDK: {len(calls)} function_call item(s)")
    for item in calls:
        print(f"  call_id={item.call_id} name={item.name} arguments={item.arguments} -> {verdict(item.arguments)}")

def messages():
    client = anthropic.Anthropic(base_url=BASE, api_key=KEY, max_retries=0)
    tools = [{"name": "read_file", "description": "Read one file from disk.", "input_schema": SCHEMA}]
    with client.messages.stream(model=MODEL, max_tokens=1024, messages=[{"role": "user", "content": PROMPT}], tools=tools) as stream:
        for event in stream:
            if event.type == "content_block_start" and event.content_block.type == "tool_use":
                print(f"content_block_start: index={event.index} id={event.content_block.id} name={event.content_block.name}")
        final = stream.get_final_message()
    blocks = [block for block in final.content if block.type == "tool_use"]
    print(f"assembled by the SDK: {len(blocks)} tool_use block(s), stop_reason={final.stop_reason}")
    for block in blocks:
        print(f"  id={block.id} name={block.name} input={json.dumps(block.input)}")

def replay():
    client = openai.OpenAI(base_url=f"{BASE}/v1", api_key=KEY, max_retries=0)
    tools = [{"type": "function", "function": {"name": "read_file", "description": "Read one file from disk.", "parameters": SCHEMA}}]
    merged_call = {"id": "call_0", "type": "function", "function": {"name": "read_fileread_file", "arguments": '{"path": "a.rs"}{"path": "b.rs"}'}}
    history = [
        {"role": "user", "content": PROMPT},
        {"role": "assistant", "content": "", "tool_calls": [merged_call]},
        {"role": "tool", "tool_call_id": "call_0", "content": "fn main() {}"},
    ]
    try:
        client.chat.completions.create(model=MODEL, messages=history, tools=tools)
        print("history holding a merged call sent back: 200 OK")
    except openai.APIStatusError as exc:
        print(f"history holding a merged call sent back: HTTP {exc.status_code} {str(exc.message)[:300]}")

def replay_no_argument_call(arguments, label):
    client = openai.OpenAI(base_url=f"{BASE}/v1", api_key=KEY, max_retries=0)
    tools = [{"type": "function", "function": {"name": "list_files", "description": "List the files in the project.", "parameters": {"type": "object", "properties": {}}}}]
    no_argument_call = {"id": "call_0", "type": "function", "function": {"name": "list_files", "arguments": arguments}}
    history = [
        {"role": "user", "content": "Which files are in the project?"},
        {"role": "assistant", "content": "", "tool_calls": [no_argument_call]},
        {"role": "tool", "tool_call_id": "call_0", "content": "a.rs b.rs"},
    ]
    try:
        reply = client.chat.completions.create(model=MODEL, messages=history, tools=tools)
        print(f"history holding a call with {label} sent back: 200 OK, reply {reply.choices[0].message.content!r:.80}")
    except openai.APIStatusError as exc:
        print(f"history holding a call with {label} sent back: HTTP {exc.status_code} {str(exc.message)[:300]}")

def replay_empty():
    replay_no_argument_call("", "empty arguments")

def replay_null():
    replay_no_argument_call("null", 'arguments "null"')

{"chat": chat, "responses": responses, "messages": messages, "replay": replay, "replay_empty": replay_empty, "replay_null": replay_null}[sys.argv[1]]()

Each case matched on all 3 runs

Case Before (831a14c) After (2fd636e)
OpenCode, two parallel reads 1 read 2 reads, at 9dd965188fb
chat, turn 1 1 glued call 2 valid calls
chat, turn 2 HTTP 500 Extra data 200 OK
responses, two parallel calls SDK error, unfinished items 2 function_call items
messages, two parallel calls 2 tool_use blocks 2 tool_use blocks
replay, a glued call HTTP 500 HTTP 400 naming call_0
replay_empty HTTP 500 Expecting value 200 OK
replay_null, arguments "null" 200 OK 200 OK

Before (831a14c)

Proxy boot

Both legs drop --reload, since uvicorn then ignores --num_workers

tree /tmp/wt_lts_1_108_x_49183_base HEAD 831a14c8f48e189e24a85b47da1b31b44e0718b6 porcelain=[]
$ .venv/bin/python litellm/proxy/proxy_cli.py --config qa_config_ltsb.yaml --port 26471 --num_workers 2 --detailed_debug --use_v2_migration_resolver --timeout_worker_healthcheck 60
INFO:     Uvicorn running on http://0.0.0.0:26471 (Press CTRL+C to quit)
INFO:     Started server process [84832]
INFO:     Started server process [84833]

OpenCode, two parallel reads

  1. Start opencode on port 26471 in a folder holding a.rs and b.rs, and send the prompt above
  2. Trial 2 of 3 runs one read, then guesses at b.rs

pr50718-831a14c8f4-oc_ltsb_2.png

Pane text, trial 2
┃  Read the files a.rs and b.rs. Call the read tool once for each file, both calls at once.
+ Thought: 440ms
→ Read a.rs
+ Thought: 694ms
The file a.rs has a single line: 1: pub fn alpha() -> u32 { 1 }. The file ends. The file b.rs (assuming it
exists) would similarly have a content line. Let me know if you need further assistance!
▣  Build · qwen3:0.6b on Ollama via LiteLLM · 33.2s
  1. Trials 1 and 3 also run one read each
Trials 1 and 3

pr50718-831a14c8f4-oc_ltsb_1.png

+ Thought: 1.2s
⠧ Read /home/opencode/a.rs
▣  Build · qwen3:0.6b on Ollama via LiteLLM
┃  △ Permission required
┃    ← Access external directory /home/opencode

pr50718-831a14c8f4-oc_ltsb_3.png

+ Thought: 554ms
→ Read a.rs
+ Thought: 1.4s
The file a.rs has a function alpha() returning u32(1). The file ends with a line marking 1 line. For b.rs, the
content is not provided, so I cannot confirm its contents. Let me know if you need further details.
▣  Build · qwen3:0.6b on Ollama via LiteLLM · 42.1s

Client cases

  1. Run qa_client.py <case> three times for each case below
chat, 3 runs
$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py chat
turn 1 delta: index=0 id=7523cad1-99e8-4c26-8496-f33222162e76 name=read_file arguments={"path": "a.rs"}
turn 1 delta: index=0 id=fe64a171-ac9b-498a-bb2d-332613344712 name=read_file arguments={"path": "b.rs"}
turn 1 assembled by the SDK: 1 tool call(s)
  name=read_fileread_file arguments={"path": "a.rs"}{"path": "b.rs"} -> NOT JSON (Extra data: line 1 column 17 (char 16))
turn 2 (tool results sent back): HTTP 500 Error code: 500 - litellm.APIConnectionError: Extra data: line 1 column 17 (char 16)

$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py chat
turn 1 delta: index=0 id=69de4e31-04b5-4836-b977-e6ecb00ce4f9 name=read_file arguments={"path": "a.rs"}
turn 1 delta: index=0 id=b3f091a4-b9b1-4a1f-97ef-5724db0faaa0 name=read_file arguments={"path": "b.rs"}
turn 1 assembled by the SDK: 1 tool call(s)
  name=read_fileread_file arguments={"path": "a.rs"}{"path": "b.rs"} -> NOT JSON (Extra data: line 1 column 17 (char 16))
turn 2 (tool results sent back): HTTP 500 Error code: 500 - litellm.APIConnectionError: Extra data: line 1 column 17 (char 16)

$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py chat
turn 1 delta: index=0 id=a9537262-867c-41f8-847d-12f5c7c4f304 name=read_file arguments={"path": "a.rs"}
turn 1 delta: index=0 id=ebd0feb9-c55b-4d41-b04d-85a57ee2c7b8 name=read_file arguments={"path": "b.rs"}
turn 1 assembled by the SDK: 1 tool call(s)
  name=read_fileread_file arguments={"path": "a.rs"}{"path": "b.rs"} -> NOT JSON (Extra data: line 1 column 17 (char 16))
turn 2 (tool results sent back): HTTP 500 Error code: 500 - litellm.APIConnectionError: Extra data: line 1 column 17 (char 16)
replay, 3 runs
$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay
history holding a merged call sent back: HTTP 500 Error code: 500 - litellm.APIConnectionError: Extra data: line 1 column 17 (char 16)

$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay
history holding a merged call sent back: HTTP 500 Error code: 500 - litellm.APIConnectionError: Extra data: line 1 column 17 (char 16)

$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay
history holding a merged call sent back: HTTP 500 Error code: 500 - litellm.APIConnectionError: Extra data: line 1 column 17 (char 16)
replay_empty and replay_null, 3 runs each
$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_empty
history holding a call with empty arguments sent back: HTTP 500 Error code: 500 - litellm.APIConnectionError: Expecting value: line 1 column 1 (char 0)

$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_empty
history holding a call with empty arguments sent back: HTTP 500 Error code: 500 - litellm.APIConnectionError: Expecting value: line 1 column 1 (char 0)

$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_empty
history holding a call with empty arguments sent back: HTTP 500 Error code: 500 - litellm.APIConnectionError: Expecting value: line 1 column 1 (char 0)

$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_null
history holding a call with arguments "null" sent back: 200 OK, reply 'The files in the project are:\n- a.rs\n- b.rs'

$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_null
history holding a call with arguments "null" sent back: 200 OK, reply 'The files in the project are:\n- `a.rs`\n- `b.rs`'

$ BASE=http://127.0.0.1:26471 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_null
history holding a call with arguments "null" sent back: 200 OK, reply 'The files in the project are `a.rs` and `b.rs`.'

responses and messages

  1. Boot the Before tree again, then run qa_client.py responses and qa_client.py messages three times each
Proxy boot for this run
tree /tmp/wt_lts_1_108_x_49183_base HEAD 831a14c8f48e189e24a85b47da1b31b44e0718b6 porcelain=[]
$ .venv/bin/python litellm/proxy/proxy_cli.py --config qa_config_ltsb.yaml --port 29934 --num_workers 2 --detailed_debug --use_v2_migration_resolver --timeout_worker_healthcheck 60
INFO:     Uvicorn running on http://0.0.0.0:29934 (Press CTRL+C to quit)
INFO:     Started server process [75897]
INFO:     Started server process [75898]
responses and messages, 3 runs each
$ BASE=http://127.0.0.1:29934 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py responses
output_item.added: output_index=1 call_id=43b20e16-5215-4fa4-b75d-4bcdcf49ff37 name=read_file
output_item.added: output_index=2 call_id=6bb0baa0-cf1e-46af-81b7-efd053fd4b95 name=read_file
Traceback (most recent call last): [SDK frames trimmed]
RuntimeError: Cannot complete response with unfinished output items.

$ BASE=http://127.0.0.1:29934 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py responses
output_item.added: output_index=1 call_id=2c72cc4a-8247-4994-a37c-dd4820cfa3d1 name=read_file
output_item.added: output_index=2 call_id=8264d1b8-3016-43b3-b49d-c19bdbcc4c67 name=read_file
Traceback (most recent call last): [SDK frames trimmed]
RuntimeError: Cannot complete response with unfinished output items.

$ BASE=http://127.0.0.1:29934 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py responses
output_item.added: output_index=1 call_id=6683ec3a-5013-4821-84f1-628c717e7e9d name=read_file
output_item.added: output_index=2 call_id=c1436cf0-1e00-42cb-bd5d-ec15cf5fbb66 name=read_file
Traceback (most recent call last): [SDK frames trimmed]
RuntimeError: Cannot complete response with unfinished output items.

$ BASE=http://127.0.0.1:29934 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py messages
content_block_start: index=1 id=d92b4095-4f3a-4519-83b6-21e5b5d2926f name=read_file
content_block_start: index=2 id=6f57612c-99e0-4569-9891-084ee5c5112f name=read_file
assembled by the SDK: 2 tool_use block(s), stop_reason=tool_use
  id=d92b4095-4f3a-4519-83b6-21e5b5d2926f name=read_file input={"path": "a.rs"}
  id=6f57612c-99e0-4569-9891-084ee5c5112f name=read_file input={"path": "b.rs"}

$ BASE=http://127.0.0.1:29934 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py messages
content_block_start: index=1 id=b743f2fb-02cd-42b2-b8ea-aa30f87e9a3d name=read_file
content_block_start: index=2 id=70f4a3e1-a993-4351-b341-f8dd898244e4 name=read_file
assembled by the SDK: 2 tool_use block(s), stop_reason=tool_use
  id=b743f2fb-02cd-42b2-b8ea-aa30f87e9a3d name=read_file input={"path": "a.rs"}
  id=70f4a3e1-a993-4351-b341-f8dd898244e4 name=read_file input={"path": "b.rs"}

$ BASE=http://127.0.0.1:29934 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py messages
content_block_start: index=1 id=f8686e6d-e272-4ff7-a3e9-72aaa3849898 name=read_file
content_block_start: index=2 id=12ce71de-c919-4369-832d-ab7de5c5b70a name=read_file
assembled by the SDK: 2 tool_use block(s), stop_reason=tool_use
  id=f8686e6d-e272-4ff7-a3e9-72aaa3849898 name=read_file input={"path": "a.rs"}
  id=12ce71de-c919-4369-832d-ab7de5c5b70a name=read_file input={"path": "b.rs"}

After (2fd636e)

Proxy boot
tree /tmp/wt_lts_1_108_x_49183 HEAD 2fd636e6103b48968bd76acb63b9860f311dfd9d porcelain=[]
$ .venv/bin/python litellm/proxy/proxy_cli.py --config qa_config_ltsa.yaml --port 20861 --num_workers 2 --detailed_debug --use_v2_migration_resolver --timeout_worker_healthcheck 60
INFO:     Uvicorn running on http://0.0.0.0:20861 (Press CTRL+C to quit)
INFO:     Started server process [91420]
INFO:     Started server process [91419]

OpenCode, two parallel reads

These trials ran at 9dd965188fb. Later commits change only how replays are parsed and logged, and the merged line changes do not touch Ollama

  1. Same steps as Before, pointed at port 27571
  2. Trial 2 of 3 runs both reads and describes alpha() and beta()

pr50718-9dd965188f-oc_ltsa_2.png

Pane text, trial 2
┃  Read the files a.rs and b.rs. Call the read tool once for each file, both calls at once.
+ Thought: 677ms
→ Read a.rs
→ Read b.rs
+ Thought: 600ms
The files a.rs and b.rs have been successfully read. The contents show the implementation of alpha() and beta()
 functions, each returning a u32. No further actions are needed for this task.
▣  Build · qwen3:0.6b on Ollama via LiteLLM · 28.4s
  1. Trials 1 and 3 also run both reads, on paths the small model guessed
Trials 1 and 3

pr50718-9dd965188f-oc_ltsa_1.png

+ Thought: 478ms
⠇ Read /path/a.rs [limit=2000, offset=0]
⠧ Read /path/b.rs [limit=2000, offset=0]
▣  Build · qwen3:0.6b on Ollama via LiteLLM
┃  △ Permission required
┃    ← Access external directory /path

pr50718-9dd965188f-oc_ltsa_3.png

+ Thought: 293ms
⠙ Read /Users/mateo/Development/a.rs
⠙ Read /Users/mateo/Development/b.rs
▣  Build · qwen3:0.6b on Ollama via LiteLLM
┃  △ Permission required
┃    ← Access external directory /Users/mateo/Development

Client cases

  1. Same as Before
chat, 3 runs
$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py chat
turn 1 delta: index=0 id=c8cb51e3-f8f3-4317-9ab7-c8aac125352b name=read_file arguments={"path": "a.rs"}
turn 1 delta: index=1 id=316f7e2a-4042-43ce-aea1-c39f2486c989 name=read_file arguments={"path": "b.rs"}
turn 1 assembled by the SDK: 2 tool call(s)
  name=read_file arguments={"path": "a.rs"} -> valid JSON
  name=read_file arguments={"path": "b.rs"} -> valid JSON
turn 2 (tool results sent back): 200 OK, reply 'The function calls for reading `a.rs` and `b.rs` are successfully made. However,'

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py chat
turn 1 delta: index=0 id=e33acafc-6cf1-445d-8b94-69657eaff9c6 name=read_file arguments={"path": "a.rs"}
turn 1 delta: index=1 id=c43aa058-fede-401c-8c07-b9c2bb986380 name=read_file arguments={"path": "b.rs"}
turn 1 assembled by the SDK: 2 tool call(s)
  name=read_file arguments={"path": "a.rs"} -> valid JSON
  name=read_file arguments={"path": "b.rs"} -> valid JSON
turn 2 (tool results sent back): 200 OK, reply "The tools have been successfully called to read the files a.rs and b.rs. Here's "

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py chat
turn 1 delta: index=0 id=f5f9cd21-eb3b-45e8-b5af-a442db57bf8e name=read_file arguments={"path": "a.rs"}
turn 1 delta: index=1 id=2ebf1bc7-6eb8-46ee-b2a7-4cdff0bbd195 name=read_file arguments={"path": "b.rs"}
turn 1 assembled by the SDK: 2 tool call(s)
  name=read_file arguments={"path": "a.rs"} -> valid JSON
  name=read_file arguments={"path": "b.rs"} -> valid JSON
turn 2 (tool results sent back): 200 OK, reply 'The code for reading the files is as follows:\n\n```rust\nfn main() {\n    // Read a'
responses and messages, 3 runs each
$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py responses
output_item.added: output_index=1 call_id=875dad8d-f11d-4d9e-92d8-8da3135ed4ee name=read_file
output_item.added: output_index=2 call_id=500aaea1-82e2-47a4-a19c-dbdc2604fa2a name=read_file
assembled by the SDK: 2 function_call item(s)
  call_id=875dad8d-f11d-4d9e-92d8-8da3135ed4ee name=read_file arguments={"path": "a.rs"} -> valid JSON
  call_id=500aaea1-82e2-47a4-a19c-dbdc2604fa2a name=read_file arguments={"path": "b.rs"} -> valid JSON

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py responses
output_item.added: output_index=1 call_id=800d6d25-8253-4a7e-a656-59cc03197b52 name=read_file
output_item.added: output_index=2 call_id=e4d38b52-4ac4-4379-a5ec-d5018a83e9ef name=read_file
assembled by the SDK: 2 function_call item(s)
  call_id=800d6d25-8253-4a7e-a656-59cc03197b52 name=read_file arguments={"path": "a.rs"} -> valid JSON
  call_id=e4d38b52-4ac4-4379-a5ec-d5018a83e9ef name=read_file arguments={"path": "b.rs"} -> valid JSON

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py responses
output_item.added: output_index=1 call_id=46cbb07e-13c7-4bf0-ab73-a367ca974fb2 name=read_file
output_item.added: output_index=2 call_id=403ae102-184c-457b-906f-b6144e31208b name=read_file
assembled by the SDK: 2 function_call item(s)
  call_id=46cbb07e-13c7-4bf0-ab73-a367ca974fb2 name=read_file arguments={"path": "a.rs"} -> valid JSON
  call_id=403ae102-184c-457b-906f-b6144e31208b name=read_file arguments={"path": "b.rs"} -> valid JSON

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py messages
content_block_start: index=1 id=6dbe04e8-d5c2-4cc0-b693-ed13eeffc942 name=read_file
content_block_start: index=2 id=568ef404-55a7-4e89-b9bf-3d0ffb05b903 name=read_file
assembled by the SDK: 2 tool_use block(s), stop_reason=tool_use
  id=6dbe04e8-d5c2-4cc0-b693-ed13eeffc942 name=read_file input={"path": "a.rs"}
  id=568ef404-55a7-4e89-b9bf-3d0ffb05b903 name=read_file input={"path": "b.rs"}

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py messages
content_block_start: index=1 id=74bbf2ad-3f70-43cd-b468-8f2ddc3d477e name=read_file
content_block_start: index=2 id=67a3e986-3d09-47f6-a639-3389a1a30dce name=read_file
assembled by the SDK: 2 tool_use block(s), stop_reason=tool_use
  id=74bbf2ad-3f70-43cd-b468-8f2ddc3d477e name=read_file input={"path": "a.rs"}
  id=67a3e986-3d09-47f6-a639-3389a1a30dce name=read_file input={"path": "b.rs"}

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py messages
content_block_start: index=1 id=8e7b2c2e-26d1-46a5-b208-2eb81a55dd63 name=read_file
content_block_start: index=2 id=85a24c8e-4dfe-4d85-82bf-1879d89c72cd name=read_file
assembled by the SDK: 2 tool_use block(s), stop_reason=tool_use
  id=8e7b2c2e-26d1-46a5-b208-2eb81a55dd63 name=read_file input={"path": "a.rs"}
  id=85a24c8e-4dfe-4d85-82bf-1879d89c72cd name=read_file input={"path": "b.rs"}
replay, 3 runs
$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay
history holding a merged call sent back: HTTP 400 Error code: 400 - litellm.BadRequestError: OllamaException - arguments of assistant tool call 'call_0' are not a JSON object

LiteLLM: model group 'ollama-qwen3' failed with the error above. No fallback was attempted.

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay
history holding a merged call sent back: HTTP 400 Error code: 400 - litellm.BadRequestError: OllamaException - arguments of assistant tool call 'call_0' are not a JSON object

LiteLLM: model group 'ollama-qwen3' failed with the error above. No fallback was attempted.

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay
history holding a merged call sent back: HTTP 400 Error code: 400 - litellm.BadRequestError: OllamaException - arguments of assistant tool call 'call_0' are not a JSON object

LiteLLM: model group 'ollama-qwen3' failed with the error above. No fallback was attempted.
replay_empty and replay_null, 3 runs each
$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_empty
history holding a call with empty arguments sent back: 200 OK, reply 'The files in the project are:\n\n- a.rs\n- b.rs'

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_empty
history holding a call with empty arguments sent back: 200 OK, reply 'The files in the project are:\na.rs  \nb.rs'

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_empty
history holding a call with empty arguments sent back: 200 OK, reply 'The files in the project are `a.rs` and `b.rs`.'

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_null
history holding a call with arguments "null" sent back: 200 OK, reply 'The files in the project are:\n- a.rs\n- b.rs'

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_null
history holding a call with arguments "null" sent back: 200 OK, reply 'The files in the project are:\n- a.rs\n- b.rs'

$ BASE=http://127.0.0.1:20861 KEY=$LITELLM_MASTER_KEY ../clientvenv/bin/python qa_client.py replay_null
history holding a call with arguments "null" sent back: 200 OK, reply 'The files in the project are:\n- a.rs\n- b.rs'

Type

🐛 Bug Fix

Caveats (if any)

Low

  • Indices follow arrival order rather than Ollama's function.index, so a server that omits or repeats that field still gets unique indices
  • A replayed glued call answers 400 rather than being split, since split calls would have no matching tool results
  • The ollama/ route still answers 500 for these histories, and it is followed up separately
  • QA used qwen3:0.6b, since newer Qwen models start at 27B
  • Shared Delta and OCI tool call numbering left untouched
  • Streamed tool call ids are still regenerated by LiteLLM (fix(ollama): keep provider-assigned tool call ids in streamed tool calls #46587)
  • The line already has 2 ruff errors in test files this PR leaves alone

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Note

Medium Risk
Touches Ollama request transformation and streaming tool-call indexing on a widely used chat path; behavior changes (400 vs 500, distinct indices) but is covered by targeted unit tests.

Overview
Backports Ollama chat fixes so parallel streamed tool calls get sequential index values across chunks (fixes clients merging every delta into index 0), and replayed assistant tool arguments go through the shared parse_tool_call_arguments path with HTTP 400 when they are not a JSON object (instead of 500 on bad JSON).

common_utils: repair warnings now log argument previews via _logged_arguments (200-char cap, full redaction when turn_off_message_logging is on) instead of echoing the raw string.

Tests cover log preview/redaction, Ollama history argument forwarding, invalid replay errors, and streaming index numbering.

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

tedswinyar and others added 7 commits November 6, 2026 13:19
Ollama streams parallel tool calls one per chunk with no top-level index, and the delta
numbers the calls of each chunk from zero, so every call left the proxy as index 0 and
OpenAI-style clients appended the arguments of each later call onto the first one. Number
the calls with a counter that lives for the whole stream instead.

Fixes BerriAI#33678

Backport of BerriAI#49183 to lts/1.108.x.
Cherry-picked from df6126e (fix-ollama-chat-stream-tool-call-index).
…t JSON

A chat history that already holds a merged tool call from an older stream
used to fail with a 500 APIConnectionError. It now answers 400 naming the
tool call. The streaming tests use Ollama's real tool call shape and drop
a case the merge base already passed.

Backport of BerriAI#49183 to lts/1.108.x.
Cherry-picked from 84154df (fix-ollama-chat-stream-tool-call-index).
…repair parser

Empty, null, and truncated arguments in a replayed assistant tool call now go through parse_tool_call_arguments, so they are forwarded as an object instead of answering 500. Arguments that still are not a JSON object answer 400 naming the call id.

Backport of BerriAI#49183 to lts/1.108.x.
Cherry-picked from 0ae806c (fix-ollama-chat-stream-tool-call-index).
Adapted to the line. parse_tool_call_arguments is imported from common_utils, its home here, and the forwarded-object test expects no tool call id, since the line does not forward ids.
…nt text out of the repair warning

Replayed tool call arguments of the JSON string "null" used to reach Ollama and return 200. The shared parser turns them into None, so they now go out as {} like empty or missing arguments instead of answering 400.

The parser's repair warning logged up to 200 characters of the arguments. It now logs only the tool name, context, and length.

Backport of BerriAI#49183 to lts/1.108.x.
Cherry-picked from e604431 (fix-ollama-chat-stream-tool-call-index).
Adapted to the line. The repair warning change goes into common_utils.py, where parse_tool_call_arguments lives here, and its test goes into that module's test file.
…error chain

Backport of BerriAI#49183 to lts/1.108.x.
Cherry-picked from 0f7003a (fix-ollama-chat-stream-tool-call-index).
…e logging is off

Backport of BerriAI#49183 to lts/1.108.x.
Cherry-picked from 5ef6d62 (fix-ollama-chat-stream-tool-call-index).
Adapted to the line. The repair warning lives in common_utils.py here.
Backport of BerriAI#49183 to lts/1.108.x.
Cherry-picked from 1f71ed3 (fix-ollama-chat-stream-tool-call-index).
Adapted to the line. The repair warning tests live in test_litellm_core_utils_prompt_templates_common_utils.py here.
@zoveki
zoveki requested a review from a team November 9, 2026 19:36
@veria-ai

veria-ai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

The PR backports streamed tool-call index handling for Ollama chat to lts/1.108.x, touching shared tool-argument repair utilities.

One issue remains open: tool-argument repair warnings can log the first 200 characters of argument contents despite request-level message redaction being enabled. This creates a limited disclosure path into logs for requests that explicitly disable message logging; no issues have been addressed yet.

Open issues (1)

Fixed/addressed: 0 · PR risk: 5/10

Reviews



def _logged_arguments(arguments: str) -> str:
if litellm.turn_off_message_logging:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: Repair warnings ignore request-level message redaction

With the global flag false, an Ollama completion using turn_off_message_logging=True or x-litellm-enable-message-redaction: true still logs the first 200 characters of repaired tool arguments; I reproduced both through litellm.completion with a mocked provider response. Pass the request’s effective redaction decision, computed by should_redact_message_logging, into the repair logger, or omit argument contents from this warning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mirrors #49183 on main, and the line today logs full arguments under every setting. Request-level redaction for this warning is a tracked follow-up

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@greptile-apps

greptile-apps Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no outstanding findings

Summary

This backports separate streamed tool-call indices to the LTS branch. Replayed arguments use the shared repair parser, and rejected arguments return HTTP 400 naming the call

The updated live proxy proof addresses the previous QA finding. No new actionable issues were found

zoveki explicitly rejected fragmented-call handling for the tested Ollama behavior and accepted the existing limits around per-request logging, unrepaired argument errors, and exception context. Those concerns were not reported again

  • Ollama chat streams give each tool call its own index.
  • Ollama chat replays tool arguments as objects or returns a clear 400.
  • Repaired-argument warnings show a short preview or hide the text.

Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/lts..." · Reviewed by Greptile

@codecov

codecov Bot commented Nov 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…rt_49183_lts_1_108_x

# Conflicts:
#	litellm/litellm_core_utils/prompt_templates/common_utils.py
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2fd636e. Configure here.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri merged commit a354fb7 into BerriAI:lts/1.108.x Nov 9, 2026
61 checks passed
kartsan03 added a commit to kartsan03/wiretruth that referenced this pull request Nov 10, 2026
…tuses (#95)

## Summary

`wiretruth lint` now checks that each stored PASS, LOSSY or WRONG grade
follows from the MUST statuses next to it, along with the other gaps
listed in #90. The same PR corrects four statements from #91: the
upstream status of BerriAI/litellm#33678, the site's Suite label, and
one sentence each in `docs/formats.md` and the README.

Closes #90
Closes #91

## Why

Rule 7 says grades are computed, never hand-edited, but nothing checked
a committed results file against its own requirement statuses.
Conformance re-runs only the pinned version of each library, and the
site and `docs/validation.md` also read the eight older files. #91
collects statements on the site and in the docs that no longer match the
repository or the upstream state.

## What changed

- `grading.py`: the step from MUST statuses to PASS, LOSSY or WRONG is
`must_grade(statuses)`. `grade_cell` calls it and keeps its rule numbers
(6, 7, 8) and `RULES`.
- `lint.py`, for each results file:
- a PASS, LOSSY or WRONG cell whose grade differs from `must_grade` of
its MUST statuses, that has no requirements, or whose observation is a
raised `internal` error (rule 5 gives CRASH) → error at
`$.cells[i].grade`;
- a duplicate requirement id → error at `$.cells[i].requirements[j].id`;
the same scenario and provider twice → error at `$.cells[i]`;
- CRASH, HANG, UNSUPPORTED and HARNESS cells are not recomputed, because
their rules depend on the run.
- `lint.py`, for `results/upstream.json`: an entry whose library has no
`results/<library>/` directory, and a `released` entry with a null or
empty `fixed_in`. Skipped when `results/` is missing, like the rest of
the results checks.
- `lint.py` also loads the built-in `shims/reference/` and `shims/liar/`
manifests, which the `shims/*/*/` glob missed (146 → 148 files).
- `results/upstream.json`: BerriAI/litellm#33678 is `fix-merged` with
`pr` set to BerriAI/litellm#49183, and `fixed_in` stays null. The
upstream merge commits are
[6a232c9](BerriAI/litellm@6a232c9)
on `main` (2026-11-09) and the backport
[a354fb7](BerriAI/litellm@a354fb7)
on `lts/1.108.x` (BerriAI/litellm#50718, merged after v1.108.4 was
tagged). The cell stays WRONG: it also needs BerriAI/litellm#46543,
which is open and keeps `reported`. No results file changes.
- Site index: no "Suite" label (it showed the highest dev suite version
among the current results files). "Updated" stays, and each results file
keeps its `suite_version`.
- `docs/formats.md`: the remark that shim manifests aren't linted is
gone, and the list of lint checks names every check above plus the
manifest schema, the manifest and `package.json` secret scan and the
packages rule.
- README Quickstart: Python libraries install into `.wiretruth/envs/`,
JavaScript libraries into `node_modules` next to their shim.
- `CHANGELOG.md`: Unreleased → Added (lint) and Changed (upstream
status, site label).

Out of scope, as #90 says: comparing a cell's requirement ids and levels
with today's scenario file, and checking that an upstream entry's
scenarios and providers still exist.

## How tested

The reproduction from #90 plus the two upstream probes, on a copy of
`suite/`, `results/` and `shims/` (the grade flipped to PASS with a
SATISFIED copy of `finish-is-other` in front, the first upstream entry's
library renamed to `no-such-lib`, one `released` entry with `fixed_in:
null`):

```text
$ wiretruth lint .
results/litellm/1.105.5.json: $.cells[4].requirements[2].id: duplicate requirement id 'finish-is-other'
results/litellm/1.105.5.json: $.cells[4].grade: PASS doesn't follow from its MUST statuses, which give WRONG
results/upstream.json: $[0].library: no results directory for 'no-such-lib'
results/upstream.json: $[5].fixed_in: a released entry must have a nonempty fixed_in
wiretruth lint: 4 errors in 2 of 148 files
```

On this branch:

```text
$ uv run ruff check . && uv run ruff format --check . && uv run mypy src
All checks passed! / 91 files already formatted / Success: no issues found in 24 source files
$ uv run pytest -q
2043 passed
$ uv run pytest -q tests/unit/test_grading.py --cov=wiretruth.grading --cov-branch
grading.py 100%
$ uv run wiretruth lint
wiretruth lint: 148 files, no errors
$ uv run wiretruth site --out _site
cells/litellm/tools.parallel-calls-stream/ollama.html shows fix-merged and links pull/49183; index.html has no "Suite"
```

Each new lint test fails with its check removed. Sample CRASH, HANG,
UNSUPPORTED and HARNESS cells, with and without contradicting statuses,
still pass.

## Results impact

none (no grade changes; the committed results files all pass the new
checks)

## Checklist

- [x] Tests added or updated
- [x] `uv run ruff check . && uv run ruff format --check . && uv run
mypy src && uv run pytest -q` pass
- [x] `uv run wiretruth lint` passes (suite data, secrets, truth)
- [x] `CHANGELOG.md` updated under `Unreleased` (if user-facing)
- [x] Docs updated (if behavior or formats changed)
- [x] New WRONG / CRASH / HANG cells have an upstream issue linked in
`results/upstream.json`: none
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.

3 participants