ch02_tool_call

show:
mock turns=2 · messages=5
live turns=2 · messages=5
scenario agent_with_one_tool
scenario agent_with_one_tool · 2.7ms · 2 turns · ended: no_tool_calls
turn 1 · 2.3ms · asked for: stock_on_hand
model mock · 2.0ms · asked for: stock_on_hand
context sent — 2 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanDo we have enough milk for the week? We need four.
tools declared to the mock model {"names": ["stock_on_hand"], "consulted": false}
context ignored by the mock model {"messages": 2, "roles": ["system", "human"]}
reply
rolecontent
[0]ai
stock_on_hand({"item": "milk"})
tool stock_on_hand · 0.2ms · given: item=milk · returned: 2
args {"item": "milk"}
result {"value": 2}
turn 2 · 0.2ms · responded with: No -- there are two in the fridge, so you are two short.
model mock · 0.2ms · responded with: No -- there are two in the fridge, so you are two short.
context sent — 4 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanDo we have enough milk for the week? We need four.
[2]ai
stock_on_hand({"item": "milk"})
[3]tool2
tools declared to the mock model {"names": ["stock_on_hand"], "consulted": false}
context ignored by the mock model {"messages": 4, "roles": ["system", "human", "ai", "tool"]}
reply
rolecontent
[0]aiNo -- there are two in the fridge, so you are two short.
ended {"reason": "no_tool_calls"}
scenario agent_with_one_tool · 1695.5ms · 2 turns · ended: no_tool_calls
turn 1 · 970.7ms · 337 in / 49 out · asked for: stock_on_hand
model live · 970.0ms (model provider 789.5 · library 180.5) · 337 in / 49 out · asked for: stock_on_hand
context sent — 2 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanDo we have enough milk for the week? We need four.
wire request
attempt
1
method
POST
url
https://api.deepseek.com/v1/chat/completions
defaulted (6)
temperature, max_tokens, top_p, stop, seed, tool_choice
headers (18)
show
acceptapplication/json
accept-encodinggzip, deflate, zstd
authorizationnot recorded
connectionkeep-alive
content-length482
content-typeapplication/json
hostapi.deepseek.com
user-agentOpenAI/Python 3.6.0
x-stainless-archarm64
x-stainless-asyncfalse
x-stainless-langpython
x-stainless-osMacOS
x-stainless-package-version3.6.0
x-stainless-raw-responsetrue
x-stainless-read-timeout60.0
x-stainless-retry-count0
x-stainless-runtimeCPython
x-stainless-runtime-version3.14.7
{
  "messages": [
    {
      "content": "You answer briefly and plainly. Use the tools you are given.",
      "role": "system"
    },
    {
      "content": "Do we have enough milk for the week? We need four.",
      "role": "user"
    }
  ],
  "model": "deepseek-flash",
  "stream": false,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "stock_on_hand",
        "description": "How many of an item are currently in stock.",
        "parameters": {
          "properties": {
            "item": {
              "enum": [
                "bread",
                "butter",
                "chips",
                "milk"
              ],
              "type": "string"
            }
          },
          "required": [
            "item"
          ],
          "type": "object"
        }
      }
    }
  ]
}
wire response
status
200
headers (15)
show
access-control-allow-credentialstrue
connectionkeep-alive
content-encodinggzip
content-typeapplication/json
dateSun, 13 Sep 2026 21:51:13 GMT
serverelb
strict-transport-securitymax-age=31536000; includeSubDomains; preload
transfer-encodingchunked
varyorigin, access-control-request-method, access-control-request-headers
via1.1 59b91fa5bb1f56f1a653604439afb430.cloudfront.net (CloudFront)
x-amz-cf-idQDH82BFwtYnluViZvRD-OuoBuRt1XLoC3mYDeR2x9tFEg3Sxk_A6Dg==
x-amz-cf-popDEN53-P6
x-cacheMiss from cloudfront
x-content-type-optionsnosniff
x-ds-trace-idbbf2ca13b6b7d3468b5e1af76e936e28
{
  "id": "73f40e73-db48-4b05-ba0e-9dbe1f8a7115",
  "object": "chat.completion",
  "created": 1789336273,
  "model": "deepseek-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "",
        "reasoning_content": "We need to check stock of milk.",
        "tool_calls": [
          {
            "index": 0,
            "id": "call_00_p5QV28xb2Cl1yVNTgtFG4108",
            "type": "function",
            "function": {
              "name": "stock_on_hand",
              "arguments": "{\"item\": \"milk\"}"
            }
          }
        ]
      },
      "logprobs": null,
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": 337,
    "completion_tokens": 49,
    "total_tokens": 386,
    "prompt_tokens_details": {
      "cached_tokens": 128
    },
    "completion_tokens_details": {
      "reasoning_tokens": 8
    },
    "prompt_cache_hit_tokens": 128,
    "prompt_cache_miss_tokens": 209
  },
  "system_fingerprint": "aeb56401ca74e127821c4f9126dcb669"
}
reply
rolecontent
[0]ai
stock_on_hand({"item": "milk"})
tool stock_on_hand · 0.7ms · given: item=milk · returned: 2
args {"item": "milk"}
result {"value": 2}
turn 2 · 724.6ms · 399 in / 37 out · responded with: Not enough. You have 2 milks in stock and need 4 — so you're short by 2.
model live · 724.6ms (model provider 715.8 · library 8.8) · 399 in / 37 out · responded with: Not enough. You have 2 milks in stock and need 4 — so you're short by 2.
context sent — 4 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanDo we have enough milk for the week? We need four.
[2]ai
stock_on_hand({"item": "milk"})
[3]tool2
wire request
attempt
1
method
POST
url
https://api.deepseek.com/v1/chat/completions
defaulted (6)
temperature, max_tokens, top_p, stop, seed, tool_choice
headers (18)
show
acceptapplication/json
accept-encodinggzip, deflate, zstd
authorizationnot recorded
connectionkeep-alive
content-length798
content-typeapplication/json
hostapi.deepseek.com
user-agentOpenAI/Python 3.6.0
x-stainless-archarm64
x-stainless-asyncfalse
x-stainless-langpython
x-stainless-osMacOS
x-stainless-package-version3.6.0
x-stainless-raw-responsetrue
x-stainless-read-timeout60.0
x-stainless-retry-count0
x-stainless-runtimeCPython
x-stainless-runtime-version3.14.7
{
  "messages": [
    {
      "content": "You answer briefly and plainly. Use the tools you are given.",
      "role": "system"
    },
    {
      "content": "Do we have enough milk for the week? We need four.",
      "role": "user"
    },
    {
      "content": null,
      "role": "assistant",
      "tool_calls": [
        {
          "type": "function",
          "id": "call_00_p5QV28xb2Cl1yVNTgtFG4108",
          "function": {
            "name": "stock_on_hand",
            "arguments": "{\"item\": \"milk\"}"
          }
        }
      ],
      "reasoning_content": "We need to check stock of milk."
    },
    {
      "content": "2",
      "role": "tool",
      "tool_call_id": "call_00_p5QV28xb2Cl1yVNTgtFG4108"
    }
  ],
  "model": "deepseek-flash",
  "stream": false,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "stock_on_hand",
        "description": "How many of an item are currently in stock.",
        "parameters": {
          "properties": {
            "item": {
              "enum": [
                "bread",
                "butter",
                "chips",
                "milk"
              ],
              "type": "string"
            }
          },
          "required": [
            "item"
          ],
          "type": "object"
        }
      }
    }
  ]
}
wire response
status
200
headers (15)
show
access-control-allow-credentialstrue
connectionkeep-alive
content-encodinggzip
content-typeapplication/json
dateSun, 13 Sep 2026 21:51:14 GMT
serverelb
strict-transport-securitymax-age=31536000; includeSubDomains; preload
transfer-encodingchunked
varyorigin, access-control-request-method, access-control-request-headers
via1.1 d9978c4c79926d2f68f210859236f550.cloudfront.net (CloudFront)
x-amz-cf-id3yIKt0LKdn7XvUX5wC3CUjIYUdq7K7_485vP-d_fAbnQQlBEHI6QJg==
x-amz-cf-popDEN53-P2
x-cacheMiss from cloudfront
x-content-type-optionsnosniff
x-ds-trace-idacdc1d4b9999f6ed556ea3876a0bccc6
{
  "id": "46805f7d-e01d-4e53-9df5-47924de68c9d",
  "object": "chat.completion",
  "created": 1789336274,
  "model": "deepseek-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Not enough. You have 2 milks in stock and need 4 \u2014 so you're short by 2.",
        "reasoning_content": "Stock is 2, need 4. Not enough."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 399,
    "completion_tokens": 37,
    "total_tokens": 436,
    "prompt_tokens_details": {
      "cached_tokens": 256
    },
    "completion_tokens_details": {
      "reasoning_tokens": 12
    },
    "prompt_cache_hit_tokens": 256,
    "prompt_cache_miss_tokens": 143
  },
  "system_fingerprint": "aeb56401ca74e127821c4f9126dcb669"
}
reply
rolecontent
[0]aiNot enough. You have 2 milks in stock and need 4 — so you're short by 2.
ended {"reason": "no_tool_calls"}