# The Agent Loop

**The Cognitive Architecture**

Clawd Bot operates on a recursive decision making process known as the Reason and Act loop. Unlike a standard chatbot that generates a single text response based on a prompt, an agent enters a cycle of thought and execution to solve a problem.

**Think**\
When a task is received, the Large Language Model first analyzes the intent. It determines if the request is a simple conversational query or a complex task requiring external tools. The model formulates a reasoning trace, breaking down the user request into logical subtasks.

**Plan**\
Based on the reasoning trace, the agent selects the appropriate tool from its available registry. If the user asks to summarize a text file, the agent selects the File System Read tool. It prepares the necessary arguments, such as the file path and encoding format.

**Act**\
The system intercepts the plan and executes the chosen tool. This happens outside the Large Language Model, in the runtime environment. The agent runs the shell command, queries the API, or navigates the browser page.

**Observe**\
The output of the action is captured. This could be the content of a file, a success message from an API, or an error log from a failed command. This observation is fed back into the context window of the Large Language Model.

**Loop or Terminate**\
The model evaluates the observation. If the observation satisfies the original request, the agent generates a final answer for the user. If the task is incomplete or if an error occurred, the agent returns to the Think phase to formulate a new plan based on the new information. This allows Clawd Bot to self correct and handle multi step workflows autonomously.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clawdtoken.xyz/3-concepts/the-agent-loop.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
