ch04_tool_failures

show:
mock turns=6 · messages=16
live turns=5 · messages=14
scenario no_tool_available
scenario no_tool_available · tools=stock_on_hand · 3.2ms · 2 turns · ended: no_tool_calls
turn 1 · 2.8ms · asked for: stock_on_hand
model mock · 2.6ms · asked for: stock_on_hand
context sent — 2 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanWhen is the next delivery of milk expected?
declared tools (1)
tooldescriptionschema
stock_on_handHow many of an item are currently in stock.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "How many of an item are currently in stock.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "stock_on_hand", "type": "object"}
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: I don't have access to delivery schedules. There are 2 units of milk in stock.
model mock · 0.2ms · responded with: I don't have access to delivery schedules. There are 2 units of milk in stock.
context sent — 4 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanWhen is the next delivery of milk expected?
[2]ai
stock_on_hand({"item": "milk"})
[3]tool2
declared tools (1)
tooldescriptionschema
stock_on_handHow many of an item are currently in stock.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "How many of an item are currently in stock.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "stock_on_hand", "type": "object"}
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]aiI don't have access to delivery schedules. There are 2 units of milk in stock.
ended {"reason": "no_tool_calls"}
scenario no_tool_available · tools=stock_on_hand · 1750.2ms · 1 turn · ended: no_tool_calls
turn 1 · 1750.0ms · 333 in / 104 out · responded with: I don't have a way to check delivery schedules — the only thing I can look up is current s... (135 more characters)
model live · 1750.0ms (model provider 1568.9 · library 181.1) · 333 in / 104 out · responded with: I don't have a way to check delivery schedules — the only thing I can look up is current s... (135 more characters)
context sent — 2 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanWhen is the next delivery of milk expected?
declared tools (1)
tooldescriptionschema
stock_on_handHow many of an item are currently in stock.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "How many of an item are currently in stock.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "stock_on_hand", "type": "object"}
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-length475
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": "When is the next delivery of milk expected?",
      "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:20 GMT
serverelb
strict-transport-securitymax-age=31536000; includeSubDomains; preload
transfer-encodingchunked
varyorigin, access-control-request-method, access-control-request-headers
via1.1 9062d4391fad2aec3a7d6f3edcebc662.cloudfront.net (CloudFront)
x-amz-cf-idhxE-Bcup_ss_UvUHRPOhtI4LEjWUpoboBAQE5naPiaCQ_tZqHowFlg==
x-amz-cf-popDEN53-P2
x-cacheMiss from cloudfront
x-content-type-optionsnosniff
x-ds-trace-id39010574e615f2490f032a98bfbc2547
{
  "id": "1e3ea953-3a95-4bc3-bfad-b6632a73ee18",
  "object": "chat.completion",
  "created": 1789336280,
  "model": "deepseek-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I don't have a way to check delivery schedules \u2014 the only thing I can look up is current stock levels. So I can't tell you when the next milk delivery is expected.\n\nIf it helps, I can check how much milk is currently in stock.",
        "reasoning_content": "The user asks about next delivery of milk. I have a tool for stock on hand, but no tool for deliveries. I should say I can't answer that. Maybe check stock? Not relevant. There's no tool for delivery schedules. Answer plainly."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 333,
    "completion_tokens": 104,
    "total_tokens": 437,
    "prompt_tokens_details": {
      "cached_tokens": 128
    },
    "completion_tokens_details": {
      "reasoning_tokens": 51
    },
    "prompt_cache_hit_tokens": 128,
    "prompt_cache_miss_tokens": 205
  },
  "system_fingerprint": "aeb56401ca74e127821c4f9126dcb669"
}
reply
rolecontent
[0]aiI don't have a way to check delivery schedules — the only thing I can look up is current stock levels. So I can't tell you when the next milk delivery is expected. If it helps, I can check how much milk is currently in stock.
ended {"reason": "no_tool_calls"}
scenario tool_exception
scenario tool_exception · tools=price_of, stock_on_hand · 1.1ms · 2 turns · ended: no_tool_calls
turn 1 · 0.9ms · asked for: price_of
model mock · 0.7ms · asked for: price_of
context sent — 2 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanHow much does milk cost right now?
declared tools (2)
tooldescriptionschema
price_ofThe current shelf price of an item.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "The current shelf price of an item.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "price_of", "type": "object"}
stock_on_handHow many of an item are currently in stock.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "How many of an item are currently in stock.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "stock_on_hand", "type": "object"}
tools declared to the mock model {"names": ["price_of", "stock_on_hand"], "consulted": false}
context ignored by the mock model {"messages": 2, "roles": ["system", "human"]}
reply
rolecontent
[0]ai
price_of({"item": "milk"})
tool price_of · 0.2ms · given: item=milk · raised: PriceServiceError (pricing service unreachable for ['milk'])
args {"item": "milk"}
failed {"exception": "PriceServiceError", "message": "pricing service unreachable for ['milk']", "decision": "report to the model; this chapter has no retry"}
turn 2 · 0.2ms · responded with: I cannot get the price of milk -- the pricing service is unreachable.
model mock · 0.2ms · responded with: I cannot get the price of milk -- the pricing service is unreachable.
context sent — 4 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanHow much does milk cost right now?
[2]ai
price_of({"item": "milk"})
[3]tool['price_of'] failed and will not succeed on a retry now. Answer without it, and say plainly that you could not get it.
declared tools (2)
tooldescriptionschema
price_ofThe current shelf price of an item.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "The current shelf price of an item.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "price_of", "type": "object"}
stock_on_handHow many of an item are currently in stock.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "How many of an item are currently in stock.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "stock_on_hand", "type": "object"}
tools declared to the mock model {"names": ["price_of", "stock_on_hand"], "consulted": false}
context ignored by the mock model {"messages": 4, "roles": ["system", "human", "ai", "tool"]}
reply
rolecontent
[0]aiI cannot get the price of milk -- the pricing service is unreachable.
ended {"reason": "no_tool_calls"}
scenario tool_exception · tools=price_of, stock_on_hand · 1835.8ms · 2 turns · ended: no_tool_calls
turn 1 · 1056.2ms · 398 in / 39 out · asked for: price_of
model live · 1055.7ms (model provider 1045.8 · library 10.0) · 398 in / 39 out · asked for: price_of
context sent — 2 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanHow much does milk cost right now?
declared tools (2)
tooldescriptionschema
price_ofThe current shelf price of an item.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "The current shelf price of an item.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "price_of", "type": "object"}
stock_on_handHow many of an item are currently in stock.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "How many of an item are currently in stock.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "stock_on_hand", "type": "object"}
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-length701
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": "How much does milk cost right now?",
      "role": "user"
    }
  ],
  "model": "deepseek-flash",
  "stream": false,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "price_of",
        "description": "The current shelf price of an item.",
        "parameters": {
          "properties": {
            "item": {
              "enum": [
                "bread",
                "butter",
                "chips",
                "milk"
              ],
              "type": "string"
            }
          },
          "required": [
            "item"
          ],
          "type": "object"
        }
      }
    },
    {
      "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:22 GMT
serverelb
strict-transport-securitymax-age=31536000; includeSubDomains; preload
transfer-encodingchunked
varyorigin, access-control-request-method, access-control-request-headers
via1.1 4bb08411ba89edb53d3520e2681c55f2.cloudfront.net (CloudFront)
x-amz-cf-idn8x41mhEDib9nzE-I2nxkCgxlvtTateyh3D1wpdMF8rkusVan48zpw==
x-amz-cf-popDEN52-P3
x-cacheMiss from cloudfront
x-content-type-optionsnosniff
x-ds-trace-id615c418b76cda7f1209123f8f2914674
{
  "id": "b67a0fbe-ba2b-4ada-9af0-74805c834a03",
  "object": "chat.completion",
  "created": 1789336282,
  "model": "deepseek-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "",
        "reasoning_content": "",
        "tool_calls": [
          {
            "index": 0,
            "id": "call_00_ET_lxqZaFO33WgKVQyQe8sK9309",
            "type": "function",
            "function": {
              "name": "price_of",
              "arguments": "{\"item\": \"milk\"}"
            }
          }
        ]
      },
      "logprobs": null,
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": 398,
    "completion_tokens": 39,
    "total_tokens": 437,
    "prompt_tokens_details": {
      "cached_tokens": 256
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0
    },
    "prompt_cache_hit_tokens": 256,
    "prompt_cache_miss_tokens": 142
  },
  "system_fingerprint": "aeb56401ca74e127821c4f9126dcb669"
}
reply
rolecontent
[0]ai
price_of({"item": "milk"})
tool price_of · 0.5ms · given: item=milk · raised: PriceServiceError (pricing service unreachable for ['milk'])
args {"item": "milk"}
failed {"exception": "PriceServiceError", "message": "pricing service unreachable for ['milk']", "decision": "report to the model; this chapter has no retry"}
turn 2 · 779.5ms · 477 in / 50 out · responded with: I couldn't get the price — the price lookup for milk failed, and retrying it won't work ri... (49 more characters)
model live · 779.5ms (model provider 771.0 · library 8.4) · 477 in / 50 out · responded with: I couldn't get the price — the price lookup for milk failed, and retrying it won't work ri... (49 more characters)
context sent — 4 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanHow much does milk cost right now?
[2]ai
price_of({"item": "milk"})
[3]tool['price_of'] failed and will not succeed on a retry now. Answer without it, and say plainly that you could not get it.
declared tools (2)
tooldescriptionschema
price_ofThe current shelf price of an item.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "The current shelf price of an item.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "price_of", "type": "object"}
stock_on_handHow many of an item are currently in stock.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "How many of an item are currently in stock.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "stock_on_hand", "type": "object"}
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-length1081
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": "How much does milk cost right now?",
      "role": "user"
    },
    {
      "content": null,
      "role": "assistant",
      "tool_calls": [
        {
          "type": "function",
          "id": "call_00_ET_lxqZaFO33WgKVQyQe8sK9309",
          "function": {
            "name": "price_of",
            "arguments": "{\"item\": \"milk\"}"
          }
        }
      ]
    },
    {
      "content": "['price_of'] failed and will not succeed on a retry now. Answer without it, and say plainly that you could not get it.",
      "role": "tool",
      "tool_call_id": "call_00_ET_lxqZaFO33WgKVQyQe8sK9309"
    }
  ],
  "model": "deepseek-flash",
  "stream": false,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "price_of",
        "description": "The current shelf price of an item.",
        "parameters": {
          "properties": {
            "item": {
              "enum": [
                "bread",
                "butter",
                "chips",
                "milk"
              ],
              "type": "string"
            }
          },
          "required": [
            "item"
          ],
          "type": "object"
        }
      }
    },
    {
      "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:23 GMT
serverelb
strict-transport-securitymax-age=31536000; includeSubDomains; preload
transfer-encodingchunked
varyorigin, access-control-request-method, access-control-request-headers
via1.1 be287e7673276d1e72db92a6f145d6f0.cloudfront.net (CloudFront)
x-amz-cf-idIjZzCppma0I-xVQYcVEqhg5q-a0U3k6IYVB41ARntXlz0bpmAmJYXg==
x-amz-cf-popDEN53-P1
x-cacheMiss from cloudfront
x-content-type-optionsnosniff
x-ds-trace-id6b15d18e0f5e7a88a9eceee639b1ea86
{
  "id": "0eda686e-b0bf-44df-a7e0-f872b650fba7",
  "object": "chat.completion",
  "created": 1789336283,
  "model": "deepseek-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I couldn't get the price \u2014 the price lookup for milk failed, and retrying it won't work right now. Sorry I can't give you the current cost.",
        "reasoning_content": "The tool failed. I should say plainly I couldn't get the price."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 477,
    "completion_tokens": 50,
    "total_tokens": 527,
    "prompt_tokens_details": {
      "cached_tokens": 256
    },
    "completion_tokens_details": {
      "reasoning_tokens": 15
    },
    "prompt_cache_hit_tokens": 256,
    "prompt_cache_miss_tokens": 221
  },
  "system_fingerprint": "aeb56401ca74e127821c4f9126dcb669"
}
reply
rolecontent
[0]aiI couldn't get the price — the price lookup for milk failed, and retrying it won't work right now. Sorry I can't give you the current cost.
ended {"reason": "no_tool_calls"}
scenario partial_failure
scenario partial_failure · tools=price_of, stock_on_hand · 0.6ms · 2 turns · ended: no_tool_calls
turn 1 · 0.4ms · asked for: price_of, stock_on_hand
model mock · 0.2ms · asked for: price_of, stock_on_hand
context sent — 2 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanHow much is milk, and how many do we have?
declared tools (2)
tooldescriptionschema
price_ofThe current shelf price of an item.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "The current shelf price of an item.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "price_of", "type": "object"}
stock_on_handHow many of an item are currently in stock.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "How many of an item are currently in stock.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "stock_on_hand", "type": "object"}
tools declared to the mock model {"names": ["price_of", "stock_on_hand"], "consulted": false}
context ignored by the mock model {"messages": 2, "roles": ["system", "human"]}
reply
rolecontent
[0]ai
price_of({"item": "milk"})
stock_on_hand({"item": "milk"})
tool price_of · 0.1ms · given: item=milk · raised: PriceServiceError (pricing service unreachable for ['milk'])
args {"item": "milk"}
failed {"exception": "PriceServiceError", "message": "pricing service unreachable for ['milk']", "decision": "report to the model; this chapter has no retry"}
tool stock_on_hand · 0.1ms · given: item=milk · returned: 2
args {"item": "milk"}
result {"value": 2}
turn 2 · 0.2ms · responded with: There are 2 milk in stock. The price is unavailable right now.
model mock · 0.2ms · responded with: There are 2 milk in stock. The price is unavailable right now.
context sent — 5 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanHow much is milk, and how many do we have?
[2]ai
price_of({"item": "milk"})
stock_on_hand({"item": "milk"})
[3]tool['price_of'] failed and will not succeed on a retry now. Answer without it, and say plainly that you could not get it.
[4]tool2
declared tools (2)
tooldescriptionschema
price_ofThe current shelf price of an item.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "The current shelf price of an item.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "price_of", "type": "object"}
stock_on_handHow many of an item are currently in stock.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "How many of an item are currently in stock.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "stock_on_hand", "type": "object"}
tools declared to the mock model {"names": ["price_of", "stock_on_hand"], "consulted": false}
context ignored by the mock model {"messages": 5, "roles": ["system", "human", "ai", "tool", "tool"]}
reply
rolecontent
[0]aiThere are 2 milk in stock. The price is unavailable right now.
ended {"reason": "no_tool_calls"}
scenario partial_failure · tools=price_of, stock_on_hand · 2289.1ms · 2 turns · ended: no_tool_calls
turn 1 · 1085.0ms · 402 in / 74 out · asked for: price_of, stock_on_hand · responded with: I'll check both.
model live · 1083.6ms (model provider 1074.0 · library 9.6) · 402 in / 74 out · asked for: price_of, stock_on_hand · responded with: I'll check both.
context sent — 2 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanHow much is milk, and how many do we have?
declared tools (2)
tooldescriptionschema
price_ofThe current shelf price of an item.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "The current shelf price of an item.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "price_of", "type": "object"}
stock_on_handHow many of an item are currently in stock.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "How many of an item are currently in stock.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "stock_on_hand", "type": "object"}
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-length709
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": "How much is milk, and how many do we have?",
      "role": "user"
    }
  ],
  "model": "deepseek-flash",
  "stream": false,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "price_of",
        "description": "The current shelf price of an item.",
        "parameters": {
          "properties": {
            "item": {
              "enum": [
                "bread",
                "butter",
                "chips",
                "milk"
              ],
              "type": "string"
            }
          },
          "required": [
            "item"
          ],
          "type": "object"
        }
      }
    },
    {
      "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:24 GMT
serverelb
strict-transport-securitymax-age=31536000; includeSubDomains; preload
transfer-encodingchunked
varyorigin, access-control-request-method, access-control-request-headers
via1.1 a7c0ba01db75946f7df3f7eaf69984b6.cloudfront.net (CloudFront)
x-amz-cf-idm5Yn-bDCoBm9vMQLTniIXcvUDIvOg-c9hJ7eTCay3PYgZNGeLQOXnw==
x-amz-cf-popDEN52-P2
x-cacheMiss from cloudfront
x-content-type-optionsnosniff
x-ds-trace-id2fbbe09778210c7eaa3847824f15e970
{
  "id": "6ce01817-be04-4ee7-8d78-4bb83247920a",
  "object": "chat.completion",
  "created": 1789336284,
  "model": "deepseek-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I'll check both.",
        "reasoning_content": "",
        "tool_calls": [
          {
            "index": 0,
            "id": "call_00_ET_fQDj2zofGac23IKPiyOc3220",
            "type": "function",
            "function": {
              "name": "price_of",
              "arguments": "{\"item\": \"milk\"}"
            }
          },
          {
            "index": 1,
            "id": "call_01_ET_nx1gZFVtORYmaVRTbL0L5632",
            "type": "function",
            "function": {
              "name": "stock_on_hand",
              "arguments": "{\"item\": \"milk\"}"
            }
          }
        ]
      },
      "logprobs": null,
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": 402,
    "completion_tokens": 74,
    "total_tokens": 476,
    "prompt_tokens_details": {
      "cached_tokens": 256
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0
    },
    "prompt_cache_hit_tokens": 256,
    "prompt_cache_miss_tokens": 146
  },
  "system_fingerprint": "aeb56401ca74e127821c4f9126dcb669"
}
reply
rolecontent
[0]aiI'll check both.
price_of({"item": "milk"})
stock_on_hand({"item": "milk"})
tool price_of · 0.7ms · given: item=milk · raised: PriceServiceError (pricing service unreachable for ['milk'])
args {"item": "milk"}
failed {"exception": "PriceServiceError", "message": "pricing service unreachable for ['milk']", "decision": "report to the model; this chapter has no retry"}
tool stock_on_hand · 0.5ms · given: item=milk · returned: 2
args {"item": "milk"}
result {"value": 2}
turn 2 · 1204.1ms · 525 in / 36 out · responded with: Milk is **2 in stock**. I couldn't get the price — that lookup failed, so I don't have it.
model live · 1204.1ms (model provider 1195.7 · library 8.4) · 525 in / 36 out · responded with: Milk is **2 in stock**. I couldn't get the price — that lookup failed, so I don't have it.
context sent — 5 message(s)
rolecontent
[0]systemYou answer briefly and plainly. Use the tools you are given.
[1]humanHow much is milk, and how many do we have?
[2]aiI'll check both.
price_of({"item": "milk"})
stock_on_hand({"item": "milk"})
[3]tool['price_of'] failed and will not succeed on a retry now. Answer without it, and say plainly that you could not get it.
[4]tool2
declared tools (2)
tooldescriptionschema
price_ofThe current shelf price of an item.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "The current shelf price of an item.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "price_of", "type": "object"}
stock_on_handHow many of an item are currently in stock.{"$defs": {"GroceryItem": {"enum": ["bread", "butter", "chips", "milk"], "type": "string"}}, "description": "How many of an item are currently in stock.", "properties": {"item": {"$ref": "#/$defs/GroceryItem"}}, "required": ["item"], "title": "stock_on_hand", "type": "object"}
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-length1320
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": "How much is milk, and how many do we have?",
      "role": "user"
    },
    {
      "content": "I'll check both.",
      "role": "assistant",
      "tool_calls": [
        {
          "type": "function",
          "id": "call_00_ET_fQDj2zofGac23IKPiyOc3220",
          "function": {
            "name": "price_of",
            "arguments": "{\"item\": \"milk\"}"
          }
        },
        {
          "type": "function",
          "id": "call_01_ET_nx1gZFVtORYmaVRTbL0L5632",
          "function": {
            "name": "stock_on_hand",
            "arguments": "{\"item\": \"milk\"}"
          }
        }
      ]
    },
    {
      "content": "['price_of'] failed and will not succeed on a retry now. Answer without it, and say plainly that you could not get it.",
      "role": "tool",
      "tool_call_id": "call_00_ET_fQDj2zofGac23IKPiyOc3220"
    },
    {
      "content": "2",
      "role": "tool",
      "tool_call_id": "call_01_ET_nx1gZFVtORYmaVRTbL0L5632"
    }
  ],
  "model": "deepseek-flash",
  "stream": false,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "price_of",
        "description": "The current shelf price of an item.",
        "parameters": {
          "properties": {
            "item": {
              "enum": [
                "bread",
                "butter",
                "chips",
                "milk"
              ],
              "type": "string"
            }
          },
          "required": [
            "item"
          ],
          "type": "object"
        }
      }
    },
    {
      "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:25 GMT
serverelb
strict-transport-securitymax-age=31536000; includeSubDomains; preload
transfer-encodingchunked
varyorigin, access-control-request-method, access-control-request-headers
via1.1 939f768b06599c7357e62de464fd9a12.cloudfront.net (CloudFront)
x-amz-cf-idm9gcIBMszRxPx0hzfW4aP8Fx7i2m6bjhYFrAYugzriqodSUkkxN0VQ==
x-amz-cf-popDEN53-P1
x-cacheMiss from cloudfront
x-content-type-optionsnosniff
x-ds-trace-id4e2a677ebfd5fd890e17a3893716c249
{
  "id": "6bad2bc9-b70b-482c-a3e5-f85dfc959390",
  "object": "chat.completion",
  "created": 1789336285,
  "model": "deepseek-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Milk is **2 in stock**. I couldn't get the price \u2014 that lookup failed, so I don't have it.",
        "reasoning_content": "The price call failed. Report that honestly."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 525,
    "completion_tokens": 36,
    "total_tokens": 561,
    "prompt_tokens_details": {
      "cached_tokens": 384
    },
    "completion_tokens_details": {
      "reasoning_tokens": 9
    },
    "prompt_cache_hit_tokens": 384,
    "prompt_cache_miss_tokens": 141
  },
  "system_fingerprint": "aeb56401ca74e127821c4f9126dcb669"
}
reply
rolecontent
[0]aiMilk is **2 in stock**. I couldn't get the price — that lookup failed, so I don't have it.
ended {"reason": "no_tool_calls"}