
My hands-on learning notes from “AI Agents and Applications” by Roberto Infante
After setting up a clean Python virtual environment with LangChain, LangGraph, ChromaDB, and MCP adapters, I dove into LangGraph — the powerful framework for building reliable, stateful AI agents.
Key Takeaway: LangGraph’s State Management is a Game Changer
Unlike basic LangChain chains, LangGraph uses a graph-based architecture where every node (agent, tool, etc.) reads from and updates a shared State object.
Core Concepts I Learned:
- State Definition with Reducers
- Use TypedDict + Annotated + reducers like operator.add
- messages: Annotated[list, operator.add] → automatically appends new messages
- counter: Annotated[int, operator.add] → accumulates values
- Normal fields (e.g. user_name) get overwritten by the last write
- Building Your First Graph
- Define nodes as regular Python functions
- Connect them using add_edge() (or conditional edges later)
- Compile the graph and run with .invoke(initial_state)
- Best Practices
- Use langchain_core.messages (HumanMessage, AIMessage) for better message handling
- Keep state clean and typed for complex agent workflows
Example Output from My First Graph:
Python
🤖 Agent is thinking...
🔧 Tool is executing...
Final State:
{
'messages': [
'User: Help me with my task.',
'Hello lvydvy! I processed your request.',
'Tool finished analysis.'
],
'counter': 2,
'user_name': 'lvydvy'
}
Next Up: Persistent memory with MemorySaver, human-in-the-loop, multi-agent workflows, and Model Context Protocol (MCP).
LangGraph makes building production-grade AI agents feel structured and controllable — exactly what I needed after playing with basic LangChain chains.