Uploaded September 2026 | Updated November 2026, 4 days ago
Learn how to build a LangChain agent with create_agent, so your model picks its own tools, runs them, and remembers the conversation without you writing the loop by hand.
On Day 7 we called a tool manually: read the tool call off the AI message, run the function, build a ToolMessage, feed it back. This lesson hands all of that to create_agent. You will build a multiply tool and a live web search tool, wire them into an agent with a system prompt, then read the full message trace to see where every tool call and tool message came from. After that we swap invoke for stream to watch the agent work step by step, measure why an agent burns roughly five times the tokens of a plain model call, stop runaway tool loops with ModelCallLimitMiddleware, and attach InMemorySaver so the agent remembers earlier turns through a thread_id. Everything runs on a free OpenRouter model, so you can code along without paying anything.
๐บ Full playlist: youtube.com/playlist?list=PLW4pPr9JCovI
โฑ Chapters:
0:00 What we built in Days 1 to 7
1:29 LLM plus tools plus memory is an agent
2:34 The ReAct agent diagram
4:41 Recap of the manual tool loop from Day 7
6:10 Why one tool call creates at least four messages
8:12 tool_call_id maps each result to its tool
8:58 Interview question: do you need an agent everywhere
9:26 Why an agent costs about 5x the tokens
11:18 Setup: free Nemotron model, OpenRouter and Ollama keys
13:26 GitHub repo and the .env file
14:30 Loading env and connecting the model
15:56 Building the multiply and web search tools
19:12 create_agent with model, tools and system prompt
20:16 Visualizing the agent graph
21:04 First agent run with invoke()
22:16 Why agent input is a dict, not a string
24:31 Reading the full message trace
27:01 pretty_print: every tool call and its result
28:19 LangSmith trace and tokens per model call
29:52 invoke vs stream
31:17 stream_mode updates, step by step
33:00 Printing which node each update came from
36:18 Proving the 5x token cost in practice
39:51 The infinite tool call loop problem
40:35 How LangChain middleware intercepts requests
45:10 ModelCallLimitMiddleware in code
46:42 Hitting the limit and the exit behavior
47:44 Why the agent forgets between invokes
48:46 Adding InMemorySaver as a checkpointer
49:36 thread_id and separate chat threads
50:13 Memory in action with a follow-up question
52:13 Recap and what is next
๐ Resources:
Code and slides: github.com/laxmimerit/Langchain-10-Days-Bootcamp
Free models on OpenRouter: openrouter.ai/models
LangChain agents guide: docs.langchain.com/oss/python/langchain/agents
Prebuilt middleware docs: docs.langchain.com/oss/python/langchain/middleware/built-in
Ollama API key (free web search): ollama.com/settings/keys
Ollama web search docs: docs.ollama.com/web-search
LangChain install guide: docs.langchain.com/oss/python/langchain/install
LangSmith tracing: smith.langchain.com
UV package manager setup: youtube.com/watch?v=pcYaP1lGd3s&list=PLc2rvfiptPSQdX4jeLgW4nf5PId4j1msI&index=8
๐บ Watch next:
Tools and Tool Calling Explained: youtu.be/h4Stm0XrmKM
๐ Go deeper with my Udemy course:
Master Langchain v1 and Ollama - Chatbot, RAG and AI Agents: kgptalkie.com/langchain
If this made the agent loop clear, hit like so more beginners find it, and tell me in the comments whether your current project actually needs an agent or just a chain. Subscribe and turn on the bell, the rest of the bootcamp builds straight on this lesson.
#LangChain #AIAgents #Python #GenAI #LangGraph
Learn how to build a LangChain agent with create_agent, so your model picks its own tools, runs them, and remembers the conversation without you writing the loop by hand.
On Day 7 we called a tool manually: read the tool call off the AI message, run the function, build a ToolMessage, feed it back. This lesson hands all of that to create_agent. You will build a multiply tool and a live web search tool, wire them into an agent with a system prompt, then read the full message trace to see where every tool call and tool message came from. After that we swap invoke for stream to watch the agent work step by step, measure why an agent burns roughly five times the tokens of a plain model call, stop runaway tool loops with ModelCallLimitMiddleware, and attach InMemorySaver so the agent remembers earlier turns through a thread_id. Everything runs on a free OpenRouter model, so you can code along without paying anything.
๐บ Full playlist: youtube.com/playlist?list=PLW4pPr9JCovI
โฑ Chapters:
0:00 What we built in Days 1 to 7
1:29 LLM plus tools plus memory is an agent
2:34 The ReAct agent diagram
4:41 Recap of the manual tool loop from Day 7
6:10 Why one tool call creates at least four messages
8:12 tool_call_id maps each result to its tool
8:58 Interview question: do you need an agent everywhere
9:26 Why an agent costs about 5x the tokens
11:18 Setup: free Nemotron model, OpenRouter and Ollama keys
13:26 GitHub repo and the .env file
14:30 Loading env and connecting the model
15:56 Building the multiply and web search tools
19:12 create_agent with model, tools and system prompt
20:16 Visualizing the agent graph
21:04 First agent run with invoke()
22:16 Why agent input is a dict, not a string
24:31 Reading the full message trace
27:01 pretty_print: every tool call and its result
28:19 LangSmith trace and tokens per model call
29:52 invoke vs stream
31:17 stream_mode updates, step by step
33:00 Printing which node each update came from
36:18 Proving the 5x token cost in practice
39:51 The infinite tool call loop problem
40:35 How LangChain middleware intercepts requests
45:10 ModelCallLimitMiddleware in code
46:42 Hitting the limit and the exit behavior
47:44 Why the agent forgets between invokes
48:46 Adding InMemorySaver as a checkpointer
49:36 thread_id and separate chat threads
50:13 Memory in action with a follow-up question
52:13 Recap and what is next
๐ Resources:
Code and slides: github.com/laxmimerit/Langchain-10-Days-Bootcamp
Free models on OpenRouter: openrouter.ai/models
LangChain agents guide: docs.langchain.com/oss/python/langchain/agents
Prebuilt middleware docs: docs.langchain.com/oss/python/langchain/middleware/built-in
Ollama API key (free web search): ollama.com/settings/keys
Ollama web search docs: docs.ollama.com/web-search
LangChain install guide: docs.langchain.com/oss/python/langchain/install
LangSmith tracing: smith.langchain.com
UV package manager setup: youtube.com/watch?v=pcYaP1lGd3s&list=PLc2rvfiptPSQdX4jeLgW4nf5PId4j1msI&index=8
๐บ Watch next:
Tools and Tool Calling Explained: youtu.be/h4Stm0XrmKM
๐ Go deeper with my Udemy course:
Master Langchain v1 and Ollama - Chatbot, RAG and AI Agents: kgptalkie.com/langchain
If this made the agent loop clear, hit like so more beginners find it, and tell me in the comments whether your current project actually needs an agent or just a chain. Subscribe and turn on the bell, the rest of the bootcamp builds straight on this lesson.
#LangChain #AIAgents #Python #GenAI #LangGraph










