
Understand OpenClaw by Building One - 1: Every Agent Starts as a Loop
1. Every Agent Starts as a Loop 2. Gear up Your Agent 3. Pack the Conversation And Carry On 4. Beyond the CLI 5. Many of Them 6. Agents are Running, Your are Sleeping 7. More Context! More Context! All code snippets and working code bases are available at this repo . Every Agent Starts as a Loop Strip away the buzzwords, and an agent is just a chat loop that sometimes executes code. The core is maybe 20 lines: while True : user_input = await get_user_input () response = await session . chat ( user_input ) display ( response ) That's it. No magic. The session.chat() method sends messages to the LLM and returns the response. You already know this pattern. Tools Transform Talk into Action What makes an "agent" different from a "chatbot" is tools calls. The LLM decides when to use them. Your job is to define what tools exist and how to run them. The pattern is simple, define a tool schema, let the LLM decide when to call it, execute it, feed the result back. class BaseTool ( ABC ): name :
Continue reading on Dev.to
Opens in a new tab


