A Tour of Agents
LearnCompareBlog
Source

Lesson 3: The Agent Loop — A Tour of Agents

The agent loop is a while loop: call the LLM, execute tools, repeat until done. Build the core loop behind LangChain AgentExecutor and OpenAI Agents SDK.

The Agent Loop This is the most important lesson. Everything after this builds on this loop. You've seen this happen in Claude: you ask it to analyze a codebase, and it searches files, reads them, searches again, reads more — multiple steps before giving you an answer. Or ChatGPT with Code Interpreter: it writes code, runs it, sees an error, fixes it, runs again. That's this loop. L2's agent made one tool call and stopped. Real agents loop: call a tool → see the result → decide what's next → repeat until done. The LLM decides when to stop. No tool_calls in the response = done. This is the entire runtime of LangChain's AgentExecutor.

Concepts covered

  • agent loop
  • multi-turn
  • tool protocol
  • convergence

Framework comparison: LangChain AgentExecutor, OpenAI Agents SDK, AutoGen — a while loop over messages.

All lessons in this course

  1. Lesson 1: The Agent Function
  2. Lesson 2: Tools = Dict
  3. Lesson 3: The Agent Loop
  4. Lesson 4: Conversation
  5. Lesson 5: State = Dict
  6. Lesson 6: Memory
  7. Lesson 7: Policy = Guardrails
  8. Lesson 8: Self-Scheduling
  9. Lesson 9: The Whole Thing
3 / 9