An LLM doesn't lie: it completes. When you ask it to summarize the activity of a repo it can't read, it produces the most plausible continuation — a believable but invented roadmap. The problem isn't the model, it's that we cut off its access to reality.
This is the tipping point I describe in from a prompt to agentic: giving tools means going from “guessing” to “fetching.”
A tool is three things: a name, a description (in natural language — that's what the model reads), and an input schema. The model decides when to call it from the description — so it matters as much as the code.
You bind the tools to the model. Each turn, it can either answer or request a tool call. The node executes the call, feeds the result back, and hands control back to the model — that’s the agentic loop.
Giving tools isn't enough: you must frame their use, otherwise the agent loops, over-calls, or ignores the tools and invents anyway.
Say when to use the tool, not just what it does. “Call before summarizing a roadmap” guides better than “reads GitLab.”
A max-iterations counter prevents an agent from spinning on tool calls without ever concluding.
A Zod output schema: if the model returns a mistyped field, send it back to fix instead of crashing.
Without tracing, a tooled agent is undebuggable. You see which tool was called, with what, and what it returned.
The most dangerous tool is the one that writes. Read tools are safe; for those that modify (create, delete), add a human confirmation — that’s the whole point of human-in-the-loop, for real.
The input schema isn't paperwork: it's the contract that stops the model from improvising. In strict mode, the provider guarantees the produced arguments match the schema exactly — no invented field, no fuzzy type. On the Anthropic side you add `strict: true` to the definition; on OpenAI, the same flag requires `additionalProperties: false` and every field in `required` (an optional field is modeled as a union with `null`).
With Zod, you write the schema once and LangChain converts it to JSON Schema for the tool call, then validates and parses the response on the fly — no manual parsing on your end (structured output docs). So the same Zod object both describes the input to the model and checks the output before letting it continue.
A `user` parameter invites the model to guess: an id? a name? an email? A `user_id` parameter leaves no choice. Anthropic sums this up as the “intern test”: if a new hire can't use the tool from the description and field names alone, neither can the model (writing tools for agents).
Strict mode guarantees the *shape*, not the *meaning*. A JSON Schema can't express which field combinations make sense or which conventions your API expects — that stays on the description and your business-level validation.
Even well described, a tool sometimes returns an error, or the model passes an argument your business validation rejects. The right reaction isn't to crash: it's to send the error back *to the model* as a tool result, with an actionable message, so it fixes it on the next turn. Anthropic recommends “specific and actionable” messages over opaque codes (writing tools for agents).
A correction loop with no ceiling is an agent that can loop forever (and burn tokens) on an argument it will never produce. Keep the iteration counter from section 04 on the retry loop too.
The more tools you give, the more the model picks the wrong target and the more context fills up. Anthropic advises staying under ~20 active tools and consolidating: one `schedule_event` beats `list_users` + `list_events` + `create_event`. Beyond that, switch to on-demand tool discovery instead of loading everything into context.
“Works on my example” isn't enough. You evaluate tool use at three levels: the final answer, the isolated step (did it pick the right tool?), and the whole *trajectory* (did it follow the right chain of calls?). The `agentevals` package ships ready-made evaluators: strict, unordered, or subset match on the expected tool calls.
These evals run on the tracing from section 04: without a trace of which tool was called with what, you can neither debug nor score. Tracing is the foundation, evaluation is what you build on top.
When the agent should ask vs decide alone, and how to interrupt then resume a durable run.
The architecture that survives a traffic spike: EC2 for the site, RDS for the database, S3 + Lambda for WebP-optimized product photos.