Tools / when the model reaches into the world
Tool definitions let `respond` call external functions — live stock, current prices, EMI options — before generating an answer. Every tool added is a new failure mode: APIs time out, parameters get hallucinated, failures are invisible without instrumentation.
Architectural Position
- fn
- The LLM call — respond can now invoke external functions
- query_user
- The current user message
- state
- Conversation history
- memory
- Persistent user profile
- context
- Retrieved phone data and user profile
- tools
- A set of typed, callable functions exposed to the model
- response
- A response that may include real-world data — live stock, current prices, EMI options
Step by Step
# The failure from Layer 6
User: "Is the Pixel 9a in stock at
Croma Koramangala?"
Pipeline has:
✓ phones.json (static specs)
✓ user_profile.json (preferences)
✗ live inventory data
✗ current pricing
✗ any external system access
# The model either guesses or declinesThe pipeline knows the phones. It does not know the world. Tools close this gap.
Implementation
What you build
- Tool definitions for
check_stock(),fetch_current_price(),get_emi_options() responddecides which tools to call based onquery_user- Error handling: structured fallback
responsewhen a tool call fails
What it fixes
System answers questions requiring real-world data — stock availability, current pricing, financing options.
Key Concepts
- Tool / Function calling
- A model feature where the model returns a structured request to invoke a function rather than a text response. You run the function and return the result.
- Tool definition
- A typed description of a tool — name, purpose, and parameter schema. The model uses this to decide when and how to call it.
- Parameter hallucination
- The model invents arguments for a tool call that do not match valid inputs — e.g. a store name that does not exist in the system.
- Graceful fallback
- A structured error response when a tool call fails — the pipeline continues with a useful partial answer rather than crashing.
The Failure
The Cascade LawEach hop multiplies failure probability. Chains compound, not add.
The user asks: "Is the Pixel 9a in stock at Croma Koramangala?" The pipeline has no way to answer. It cannot reach outside the context window. The model either guesses (likely wrong, possibly stale) or declines. Tools exist to close this gap. But every tool is a new failure mode: APIs time out, the model hallucinates parameters, failures are invisible without instrumentation. A broken tool call silently degrades response or crashes the pipeline.
What it reveals
Tool calls can fail silently. APIs time out. The model hallucinates parameters. Every tools call added is a new failure mode. Failures are invisible without instrumentation.