ResourcesAI AgentsWhat Are AI Agents?
🤖AI AgentsWhat Are AI Agents?6 min

What Are AI Agents?

A practical introduction to AI agents, how they work, why they matter, and where to start building.

📅January 25, 2025TechTwitter.ioagentsllmintro

The Core Idea

An AI agent is an LLM that can act — not just respond. It observes state, reasons about it, selects a tool or action, executes it, and loops until the task is done.

The minimal loop:

Observe → Think → Act → Observe → ...

What separates an agent from a chatbot is tool use and multi-step reasoning.


The Four Building Blocks

1. The Model (Brain)

An LLM that can follow instructions, reason step-by-step, and decide which tool to call next. GPT-4o, Claude 3.5, and Gemini 1.5 are the common choices.

2. Tools (Hands)

Functions the model can invoke — web search, code execution, database queries, API calls, file I/O. The model decides when and how to call them.

3. Memory

  • Short-term: the context window (what's in the current conversation)
  • Long-term: vector databases, file storage, or structured KV stores the agent reads and writes across sessions

4. Orchestration

The loop that runs the agent: feed observations, get actions, execute, feed results back. Frameworks like LangGraph, CrewAI, and AutoGen handle this.


A Minimal Python Agent

import anthropic

client = anthropic.Anthropic()

tools = [
    {
        "name": "get_weather",
        "description": "Get current weather for a city",
        "input_schema": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        },
    }
]

messages = [{"role": "user", "content": "What's the weather in Tokyo?"}]

while True:
    response = client.messages.create(
        model="claude-opus-4-6",
        max_tokens=1024,
        tools=tools,
        messages=messages,
    )

    if response.stop_reason == "end_turn":
        print(response.content[0].text)
        break

    # Handle tool call
    for block in response.content:
        if block.type == "tool_use":
            result = get_weather(block.input["city"])  # your function
            messages.append({"role": "assistant", "content": response.content})
            messages.append({
                "role": "user",
                "content": [{"type": "tool_result", "tool_use_id": block.id, "content": result}],
            })

When to Use Agents

Use agents when...Don't use agents when...
Task requires multiple stepsSingle-shot Q&A
Need to query external dataPure text generation
Steps are unpredictable upfrontLatency is critical
Need to self-correct on failureSimple classification

Where to Start

  1. Claude API — native tool use, best reasoning
  2. LangGraph — stateful multi-agent graphs
  3. CrewAI — role-based agent teams
  4. Pydantic AI — type-safe agent framework