DEV Community

Cover image for Using ChatPromptTemplate with create_tool_calling_agent in LangChain (Instead of create_agent)
Yasith wijesuriya
Yasith wijesuriya

Posted on

Using ChatPromptTemplate with create_tool_calling_agent in LangChain (Instead of create_agent)

If you’ve used LangChain before, you’ve probably started with create_agent().

It works.
It’s fast.
But once you move into real agent systems (tools, memory, multi-agent, LangGraph), it starts to feel… limiting.

This post explains why I stopped using create_agent() and switched to
ChatPromptTemplate + create_tool_calling_agent instead.

What’s wrong with create_agent()?

Nothing is wrong with it — it’s just too abstract.

Some pain points I hit:

❌ Hard to control the actual prompt

❌ Message roles feel hidden

❌ Tool calls are difficult to debug

❌ Doesn’t scale well for multi-agent or graph-based flows
Enter fullscreen mode Exit fullscreen mode

If you want full control over how your agent thinks, you need to build it more explicitly.

1. ChatPromptTemplate (No hidden prompts)

Instead of relying on built-in agent prompts, I define everything myself.

Why I like this:
- I control system rules
- I control where history goes
- I control where tool reasoning lives

Nothing is magic. Everything is visible.

2. MessagesPlaceholder (This part is important)

Two placeholders matter the most:
- chat_history - Keeps conversation context
- agent_scratchpad- Stores tool calls + reasoning

3. create_tool_calling_agent (The real upgrade)

This agent:

  • Understands tool schemas
  • Decides when to call tools
  • Uses tool results in its reasoning loop Compared to create_agent(), this feels way more intentional. No guessing. No hidden behaviour.

4. AgentExecutor (Run the loop)

Set verbose=True.
Seriously. It saves hours when debugging tool behavior.

When this approach actually makes sense

Use this if you’re building:
- Research agents
- Tool-heavy workflows
- Multi-agent systems
- LangGraph pipelines

If you just want a quick demo, create_agent() is fine.
But for real systems, this pattern scales much better.

Final thoughts

> Agents don’t become powerful because of the model
They become powerful because of:

  • clear prompts
  • clear memory
  • clear tool usage

ChatPromptTemplate + create_tool_calling_agent gives you all three.

(This post is based on my own experience and opinions while working with LangChain.There’s no single “right way” to build agents — this is just the approach that worked best for me.)

Top comments (0)