Zenaique

Estimate the token tax a single tool round trip adds compared with an inline answer

Predict output·Medium·4.0 · 0·~2 min·Asked atIntelOpenAISamsung·Relevant atAnthropic
Attempt it
A chat app exposes one tool (`get_weather`) with a 180-token JSON schema. A user asks 'what is the weather in Tokyo?' (8 input tokens, system prompt 50 tokens). Two paths:

Path A, inline answer (no tools): model replies directly with a 25-token guess.

Path B, function calling round trip:
  Turn 1: prompt includes system + tool schemas + user message; model emits a `tool_call` message (40 output tokens: function name + JSON args).
  Tool executes externally (no model cost).
  Turn 2: prompt now includes everything from Turn 1 plus the tool_call assistant message plus a 60-token tool_result message; model emits the final 30-token natural language answer.

Using OpenAI style accounting where the full conversation is re-sent on every turn, compute:
  1. Total billed input tokens across Path B (sum across both turns)
  2. Total billed output tokens across Path B
  3. The Path B / Path A token cost ratio (assuming equal input and output unit price)

Report all three numbers.
TL;DR

A two-turn tool round-trip re-sends the schema and the prior assistant + tool messages on Turn 2, so a one-tool workflow with a 180-token schema costs about 7.8x what an inline answer would, dominated by input

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine asking a librarian a question. Inline answer is just talking: you ask, they answer. Tool-calling is more like writing letters. First letter: you send the question plus the rulebook of tools the librarian can use, and the librarian writes back saying 'I need to use the weather tool, give me Tokyo.' Then someone fetches the answer. Second letter: you send the original question AND the rulebook AGAIN AND the librarian's request AND the tool's reply, so the librarian has the full story to write the final answer. You paid postage for the rulebook twice and for the conversation history once. That is why a simple question with one tool can cost eight times what a direct answer would.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Function calling looks free in the SDK but is paid for in tokens, every turn. The API contract is stateless: each call re-bills the entire conversation as input, which means the schema and the prior tool exchange are paid on every subsequent turn. A simple one-tool round-trip already costs roughly 7-10x what the inline answer would, and the cost compounds badly in multi-step agents.

This deep dive walks through the token accounting on the example, generalizes to the agent case, and connects each cost component to its production mitigation.

Token accounting on Path A versus Path B

Path A is the simplest possible flow: one API call, model answers directly. Input = 50 (system) + 8 (user) = 58 tokens. Output = 25 tokens. Total = 83 tokens.

Path B requires two API calls plus an external tool execution.

Turn 1 input: the system prompt (50), the tool schema (180), and the user message (8). Total input = 238 tokens. The model emits a structured tool_call message: 40 output tokens (function name plus JSON args). The API responds, the calling code parses the tool_call and runs the tool externally. The tool returns 60 tokens worth of content (e.g., 'Tokyo, 14C, light rain, humidity 78%'). The tool execution itself is not billed to the model.

Turn 2 input: the same system, schema, and user message PLUS the prior assistant tool_call (40 tokens) PLUS the tool_result (60 tokens). Total = 50 + 180 + 8 + 40 + 60 = 338 tokens. The model finally writes the natural-language answer: 30 output tokens.

Add it up. Path B input across both turns: 238 + 338 = 576. Path B output: 40 + 30 = 70. Total: 646 tokens. Ratio against Path A's 83: 7.78x.

Look at where the cost actually lives. Of those 646 tokens, only 30 are the final user-facing answer. 70 (less than 11 percent) are model output total. 576 (almost 90 percent) are input. The single largest line item is the schema, paid twice for a total of 360 tokens, which is more than the actual answer the user gets back.

Generalizing to N-step agents
Prompt caching is the most important single mitigation
Schema minimization and tool granularity
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
Token componentPath A (inline)Path B (tool)Notes
System prompt50 in50 + 50 = 100 inPaid every turn
Tool schema0180 + 180 = 360 inPaid every turn (cacheable)
User message8 in8 + 8 = 16 inPaid every turn
Tool_call message040 out + 40 in (Turn 2)Output Turn 1, input Turn 2
Tool_result message060 inInput on Turn 2
Final answer25 out30 outTokens the user actually sees
Totals58 in + 25 out = 83576 in + 70 out = 6467.8x ratio

Real products, models, and research that use this idea.

  • Anthropic Claude tool use with explicit cache_control on the tools array routinely cuts tool-using-workflow costs by 4-8x for steady traffic, by reducing the schema re-input to a small fraction of the full input rate.
  • OpenAI's function calling auto-caches the system prompt and tools above 1024 tokens, applied automatically to recent prefix repeats; this is why high-volume tool users see lower realized prices than the published rate card.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow does the ratio change as the schema grows to 1000 tokens or shrinks to 50?
A

The schema is paid on every turn. Doubling its size doubles its contribution to the bill. The ratio versus Path A scales linearly with schema size at fixed turn count. Trimming schema verbosity is one of the highest-leverage optimizations for tool-using products.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Counting only the final answer tokens. The big cost is input: the schema is in the prompt twice (once per turn), and the tool_call and tool_result are re-fed as input on Turn 2. Plan capacity in tokens, not requests.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Explain what each API call re-sends on every turn.

  • Describe where tool schemas appear in the input.

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is the KV cache in transformer inference?
Flashcard·Easy