An agent is a system that perceives its environment, thinks critically, and takes action to achieve specific goals. This simple loop - **Observe, Think, Act** - is what makes them so effective.

## 1. Observe: The Context Window

An agent's perception and memory of the world comes from what it can "see." This happens through its **context window**, which is fed information from various sources:

*   **User Instructions:** Your direct commands and requests.
*   **System Messages:** Pre-defined guidelines on how the agent should behave.
*   **Tool Outputs:** Results from actions it has taken, like search results or data from an API.
*   **Memory:** Past interactions and learned information.

Everything the agent knows at any given moment is based on what's in its context.

## 2. Think: The LLM Brain

The "brain" of the agent is a **Large Language Model (LLM)**. The LLM processes everything in the context window to:

*   **Reason:** Analyze the situation and understand the goal.
*   **Plan:** Break down a complex task into a sequence of smaller, manageable steps.
*   **Decide:** Choose the best course of action, which often involves selecting the right tool for the job.

This is the core cognitive work of the agent, where raw information is turned into a concrete plan.

## 3. Act: The Toolbox

Once the agent has a plan, it needs to **act**. It does this by using a set of available **tools**. A tool is anything that allows the agent to interact with the world outside of its own thinking process, such as:

*   **Web Search:** To find current, relevant information.
*   **Code Execution:** To perform calculations or run complex logic.
*   **APIs:** To connect with other software and services.

The agent chooses a tool, uses it, and then **observes** the result, starting the loop over again until the goal is achieved.

## Agents vs. Chatbots

| Feature      | Traditional Chatbot | AI Agent (Observe, Think, Act) |
|:-------------|:--------------------|:-------------------------------|
| **Input**    | User query only     | User query + tool outputs + memory |
| **Process**  | Generates a reply   | Reasons and creates a plan     |
| **Output**   | Text response       | Actions via tools              |
| **Goal**     | Conversation        | Task Completion                |
