Back to lmviz
lmviz
Reset
Tool Calls
See what really happens when a model “uses a tool”
What's the weather?
Read my config file
Fix the typo on line 5
Create a new component
Run the tests
What's in this image?
Speed
Play
What the User Sees
Press Play to see a tool call in action
The Orchestration Loop
1
USER MESSAGE
Injected into context
2
SYSTEM PROMPT
Includes tool definitions as text
3
MODEL GENERATES
Outputs tool call JSON tokens
4
SYSTEM INTERCEPTS
Parses JSON, recognizes tool call
5
TOOL EXECUTES
Runs the actual function
6
RESULT INJECTED
Output added to context
7
MODEL CONTINUES
Generates natural language response
8
USER SEES ANSWER
The polished final response
System
Tool Def
Under the Hood
Token Stream
Orchestration
Full Prompt
What the model actually outputs — one token at a time
Press Play to see the model generate a tool call token by token
Build Your Own Tool
Key Takeaways
Tool calling = structured text generation.
The model produces JSON tokens one at a time, like writing a sentence.
The model doesn't “use” tools.
It outputs text that a system interprets as a tool call.
Tool definitions are prompt text.
They're injected into context like any other instruction.
The orchestration loop is the real magic.
It's the system around the model that makes tool use work.
This is why tool calling can fail.
If the model generates slightly wrong JSON, the tool call breaks. It's probabilistic.