Hello Agent, My First Agentic Loop
Feb 13, 2026 • 2 min read
I took the advice of Peter Steinberger, founder of OpenClaw, and built a hello world agentic loop from scratch.
Lex Fridman: “You said somewhere that everybody should implement an agent loop at some point in their lives.”
Peter Steinberger: “Yeah, because it’s like the Hello World in AI, you know? And it’s actually quite simple.”
Lex Fridman: “Yeah.”
Peter Steinberger: “It’s good to understand that that stuff’s not magic. You can easily build it yourself.”
Sounds easy enough.
Hello, agentic loop.
I took the advice of Peter Steinberger, founder of OpenClaw, and built a hello world agentic loop to better understand practical programming with AI agents. The conversation that inspired this project happened between Lex Fridman and Peter Steinberger on the Lex Fridman Podcast.
And to be honest, it wasn’t that difficult — but I did have a little agentic help. Which makes total sense, IMO.
A basic agentic loop looks a little something like this:
flowchart TD
startNode[Start] --> initState[InitializeState]
initState --> chooseAction[ModelChoosesAction]
chooseAction -->|CallTool| runTool[RunTool]
chooseAction -->|AskUser| waitInput[WaitForUserInput]
waitInput --> updateState
runTool --> updateState[UpdateState]
updateState --> stopCheck[CheckStopRules]
stopCheck -->|No| chooseAction
stopCheck -->|Yes| endNode[ReturnFinalAnswer]
chooseAction -->|Respond_or_Stop| endNode
My implementation ended up being a little more elaborate but only because I was having too much fun experimenting with features.
flowchart LR
entryPoint[EntryPoint src/index.ts] --> loopEngine[LoopEngine src/agent/loop.ts]
entryPoint --> agentRegistry[AgentRegistry src/agents]
loopEngine --> policy[Policy src/agent/policy.ts]
loopEngine --> context[ContextWindow src/agent/context.ts]
loopEngine --> router[ModelRouter src/llm/router.ts]
router --> llmClient[LlmClient src/llm/client.ts]
llmClient --> providers[Providers src/llm/providers]
agentRegistry --> tools[ToolRegistry src/tools/registry.ts]
loopEngine --> tools
tools --> builtins[BuiltInTools src/tools/builtins]
loopEngine --> logs[Logger src/observability/logger.ts]
loopEngine --> metrics[Metrics src/observability/metrics.ts]
I published the project on GitHub.