Have you ever wondered what actually sits inside a coding agent?
The answer is surprisingly small.
At the center of every coding agent is a loop:
messages = [system_prompt, user_task]
while True:
response = model.chat(messages, tools=tools)
messages.append(response.message)
if not response.tool_calls:
break
for call in response.tool_calls:
result = run_tool(call.name, call.arguments)
messages.append(tool_result(call.id, result))
That is the primitive.
The model looks at the conversation and decides either:
- "I can answer now"
- or "I need to use a tool"
If it asks for a tool, the harness runs that tool and feeds the result back into the conversation. Then the model gets another chance.
That is why I called my project Loop.
Not because the name is fancy. Because the loop is the thing.
The surprising part is that the model is not really "doing" file operations. The harness is. The model emits structured intent:
{
"name": "read_file",
"arguments": {
"path": "loop_cli/agent.py"
}
}
Then our code decides what that means.
That distinction matters.
The model proposes. The harness disposes.
Once you see that boundary, coding agents become much less mystical. A coding agent is not one thing. It is a model plus a runtime:
- The model reasons and chooses actions.
- The harness executes actions.
- The message history carries state.
- The loop coordinates everything.
The first version of Loop was intentionally tiny. It called an OpenAI-compatible endpoint from LM Studio, passed a few tools, executed tool calls, and stopped when there were no more tool calls.
That small version already had the core shape of a real agent.
Everything after that is engineering:
- tools
- permissions
- context management
- memory
- workspace boundaries
- CLI UX
- tests
- evals
But all of it grows around this tiny loop.
If you want to understand coding agents, start here. Build the loop yourself. Watch the model ask for a tool. Run the tool. Feed the result back.
The abstraction disappears quickly when you can see the messages move.
Takeaway
A coding agent is not magic. It is a model inside a tool-calling loop.
The loop is small. The engineering around it is where the real work begins.