Posts

Showing posts with the label Ollama

How an AI Agent Evolves: From Manual Memory to LangGraph ReactAgent

  How an AI Agent Evolves: From Manual Memory to LangGraph ReactAgent In the previous post , we built an AI agent from scratch—no framework, no orchestration layer. Just a model, some tools, and a loop. It worked, but it was stateless. The agent couldn’t remember what happened in previous turns, which limited its ability to reason across multiple steps. This post introduces memory. We’ll walk through a manual implementation using a conversation history and modular agent nodes. Then we’ll compare it to LangGraph’s prebuilt ReactAgent, which handles memory, tool routing, and multi-turn reasoning automatically. Link to full code Core Components of a Stateful Agent We’re still using the same building blocks: A local model via ChatOllama A couple of tools (add, multiply) LangChain message types (HumanMessage, ToolMessage, AIMessage) But now we’re introducing: AgentState: a structured container for memory chat_node and tool_node: modular functions that mirror LangGraph’s node-based de...

How an AI Agent Works Without a Framework

How an AI Agent Works Without a Framework: A Practical Guide AI Agents are complicated. They rely on a combination of models, tools, and messages to understand input, perform tasks, and respond intelligently. Frameworks like LangChain and LangGraph help simplify this process by organizing these parts into reusable workflows. But what happens when you build an agent without the framework? This post walks through a minimal example of an AI agent built from scratch—no orchestration layer, no abstractions. Just raw components working together. By reverse-engineering this agent, you’ll gain a deeper understanding of how frameworks work under the hood. You’re not just learning LangChain or LangGraph—you’re mastering the core mechanics that make agentic systems possible: how tools are registered, how messages are passed, and how models interact with external functions. For the full code Here -> Core Components of an Agent Agent Step-by-Step Breakdown 1. Defining a Model ChatOllama ChatOlla...