The Agent Loop and Skills
Ask a plain chatbot "which are the three biggest files in my Downloads folder?" and it can only guess. An OpenClaw agent can go and look, because a message does not trigger one model reply. It starts a loop.
The rule
Think, act, observe — repeat until the model stops asking for tools.
When a message reaches an agent, the loop goes through these stages:
- Validate the incoming message.
- Resolve the model: which provider and model this agent uses.
- Assemble the system prompt from the agent's skills and context files.
- Call the model with that prompt, the conversation so far and the new message.
- If the model asks for a tool (run a command, read a file, search the web), the loop runs it and feeds the result back, then returns to stage 4.
- When the model answers without asking for a tool, that answer is the final reply, streamed back to the chat.
If the conversation has grown too long for the model to take in, OpenClaw compacts it automatically and tries again. The next lesson covers that.
Skills come in at stage 3. A skill is a folder containing a SKILL.md file, in the AgentSkills format, whose text is injected into the system prompt. It gives the agent context, limits and step-by-step guidance for a tool or a workflow. Skills can sit in the workspace's skills/ folder, in shared folders, or inside plugins.
---
name: tidy-downloads
description: Archive old files in Downloads when the user asks for a clean-up.
---
1. Only touch files older than 30 days.
2. Move them into `Downloads/archive/`. Never delete anything.
3. Reply with how many files moved and the five largest.A skill is instructions, not code. It teaches the agent to use tools it already has, in the way you want.
The shortcut
Count the laps. Each tool call adds one lap: model, then tool, then model again. The loop ends on the first lap where the model replies without asking for anything.
Lap 1: the model asks for a tool
The prompt, including any matching skill, goes to the model. It replies: "run a command that lists Downloads by size."
The trap is believing the model runs commands. The model only asks; the loop does the running. That is why tool permissions, such as per-agent allow and deny lists, are set in OpenClaw rather than in the model.
Drills
Answer fast — trust the rule.
When does the agent loop stop?
At which stage do skills shape the loop?
What is a skill?
The model asks to read a file. Who actually reads it?
A task needs three tool calls, each depending on the result of the one before. How many model calls does the loop make?
Remember
- Think, act, observe — repeat until the model stops asking for tools.
- Count laps: each tool call adds a model call, and the last lap asks for nothing.
- Skills are markdown instructions in the system prompt; the model asks, the loop runs.
