# The tools stream mode

Recorded on 2026-11-14 on the x86 server guest with Ollama 0.31.1 on CPU. Models: qwen3:4b-instruct-2507-q4_K_M. ChatOllama settings: temperature 0, seed 42, num_ctx 16384, num_predict 512.

## stream_mode='tools': tool lifecycle events and output deltas

4 chunks

chunk 0:
{
  "event": "tool-started",
  "tool_call_id": "<uuid-1>",
  "tool_name": "slow_sum",
  "input": {
    "a": 2,
    "b": 3
  }
}

chunk 1:
{
  "event": "tool-output-delta",
  "tool_call_id": "<uuid-1>",
  "delta": {
    "partial": 2
  }
}

chunk 2:
{
  "event": "tool-output-delta",
  "tool_call_id": "<uuid-1>",
  "delta": {
    "partial": 5
  }
}

chunk 3:
{
  "event": "tool-finished",
  "tool_call_id": "<uuid-1>",
  "output": {
    "type": "ToolMessage",
    "content": "5",
    "name": "slow_sum",
    "id": "<uuid-2>",
    "tool_call_id": "<uuid-1>",
    "status": "success"
  }
}

model calls, as the model received them:
[
  {
    "model": "slow-sum",
    "call": 1,
    "messages": [
      "human: What is 2 + 3?"
    ],
    "tools": [
      "slow_sum"
    ]
  },
  {
    "model": "slow-sum",
    "call": 2,
    "messages": [
      "human: What is 2 + 3?",
      "ai: calls slow_sum",
      "tool: 5"
    ],
    "tools": [
      "slow_sum"
    ]
  }
]

## 'tools' with 'updates', version='v2'

part 0:
{
  "type": "updates",
  "data": [
    "model"
  ]
}

part 1:
{
  "type": "tools",
  "data": {
    "event": "tool-started",
    "tool_call_id": "<uuid-3>",
    "tool_name": "slow_sum",
    "input": {
      "a": 2,
      "b": 3
    }
  }
}

part 2:
{
  "type": "tools",
  "data": {
    "event": "tool-output-delta",
    "tool_call_id": "<uuid-3>",
    "delta": {
      "partial": 2
    }
  }
}

part 3:
{
  "type": "tools",
  "data": {
    "event": "tool-output-delta",
    "tool_call_id": "<uuid-3>",
    "delta": {
      "partial": 5
    }
  }
}

part 4:
{
  "type": "tools",
  "data": {
    "event": "tool-finished",
    "tool_call_id": "<uuid-3>",
    "output": {
      "type": "ToolMessage",
      "content": "5",
      "name": "slow_sum",
      "id": "<uuid-4>",
      "tool_call_id": "<uuid-3>",
      "status": "success"
    }
  }
}

part 5:
{
  "type": "updates",
  "data": [
    "tools"
  ]
}

part 6:
{
  "type": "updates",
  "data": [
    "model"
  ]
}

## emit_output_delta outside the tools mode is a no-op

updates chunks:
[
  [
    "model"
  ],
  [
    "tools"
  ],
  [
    "model"
  ]
]
