Write the Agent Loop by Hand First: What LangGraph Actually Adds
m3m3o · reddit · 2026-10-16
A developer built a shopping-assistant agent with no framework — just a small loop: the model requests tools, the loop executes them, appends results as messages, and calls again until a response has no toolcalls.
Key takeaways:
- maxsteps is a budget, not just a safety net: every loop pass is one API call, so a question needing five tool uses costs six calls.
- Rewriting it with LangGraph's createagent collapses the code to three lines, but printing the message list shows the exact same sequence — the framework runs the loop for you, it doesn't replace it.
- What the framework genuinely adds is memory (a checkpointer makes follow-up questions work), plus streaming, retries, and tracing.
His advice: write the loop once to learn it, use a framework when you ship — otherwise the loop stays magic, and you can't debug magic. The tutorial runs on a laptop without a GPU against any OpenAI-compatible endpoint, including Ollama.
More from coding & agent
- Founder wipes 30k lines of tech debt in one shot with Opus — lucasmeijer · 2026-10-16
- Japanese engineer runs an AI agent org inside tmux: per-project teams, one human talking to the orchestrator — 4310sy · 2026-10-16
- gloria-mcp ships an MCP server serving Gloria AI's curated crypto news — modelcontextprotocol · 2026-10-16
- Pine Script MCP server lets AI agents read v6 docs and validate syntax — modelcontextprotocol · 2026-10-16
- Open-source ebook2audiobook turns any ebook into a free audiobook, 20.4k GitHub stars — thisguyknowsai · 2026-10-16
- Composing music with math patterns via Gemini agents in Antigravity CLI — fofrAI · 2026-10-16