When learning LangChain or building AI agents, one question confused me early on:
If LLMs can decide which tool to use, why do we still execute the tool ourselves in code?
At first glance, this feels redundant — but understanding this distinction is critical if you want to build production-grade agentic systems.
Let’s break down ReAct vs Tool Calling, and why tool execution must stay outside the LLM.
ReAct: Reason + Act (Old but Important)
In the ReAct pattern, the LLM produces plain text reasoning, like:
Thought: I need the length of the word "LangChain"
Action: get_text_length
Action Input: LangChain`
As developers, we:
- Parse the text
- Decide whether the action is valid
- Execute the tool
- Feed the result back to the model
Problems with ReAct:
- Text parsing is brittle
- Hard to validate or audit
- Easy to hallucinate actions
- Difficult to scale reliably
ReAct was powerful — but not safe or structured enough for production.
Tool Calling: Structured Decisions, Safer Systems
Tool calling improves on ReAct by letting the LLM return structured intent, for example:
{
"tool_calls": [
{
"name": "get_text_length",
"args": { "text": "LangChain" }
}
]
}
Here’s the key shift:
The LLM is not executing the tool —
it is requesting the tool to be executed.
This is not a limitation.
This is a feature.
Why the LLM Should NOT Execute Tools
Even with tool calling, the execution is handled by your code (agent runtime). Why?
Because LLMs:
- Cannot safely execute code
- Should not access databases or APIs directly
- Must not trigger irreversible actions (calls, payments, emails)
Instead, we separate responsibilities:
LLM → decides intent
Runtime → validates + executes
LLM → reasons on the result
This separation enables:
- Security & sandboxing
- Retry and timeout logic
- Observability (LangSmith, tracing)
- Deterministic behavior
- Compliance and auditability
This is why, in LangChain examples, when you observe invoking the tool manually — not because the LLM can’t decide, but because it shouldn’t execute.
Mental Model That Finally Clicked for Me
❌ Wrong model
“LLM decides and executes tools”
✅ Correct model
LLM decides → system executes → LLM reasons
This is the same pattern used in:
- LangGraph
- Multi-agent workflows
- Production AI systems
- Real-world agent platforms
Why This Matters in Real Systems
If you’re building:
- AI agents
- RAG pipelines
- Conversational bots
- Outbound calling agents
- Workflow automation
You must keep execution outside the model.
LLMs reason.
Systems act.
Closing
ReAct taught us how agents think.
Tool calling teaches us how agents behave safely.
Once this clicked for me, agent architectures finally made sense.
If you’re learning LangChain or building agentic systems, I’d love to hear:
what part confused you the most at first?
Top comments (0)