Skip to content

Getting Started with AI Agents: A Developer's Introduction

Welcome to the developer’s guide to AI agents and agentic workflows.

Who This Is For

This guide is written for developers and technical users who want to understand AI agents beyond the hype — how they actually work, how to build them, and how to make them reliable in production.

You don’t need a background in machine learning or AI research. You do need to be comfortable reading and writing Python, and familiar with concepts like REST APIs and JSON. Most examples in this guide are runnable with just a pip install and an API key.

The guide deliberately avoids framework lock-in. You’ll see examples using the raw Claude API alongside examples using LangChain, CrewAI, and AutoGen. Understanding how agents work at the API level makes it much easier to use (and debug) frameworks that abstract over those fundamentals.

What You’ll Learn

Working through this guide, you’ll understand:

  • What AI agents are and how they differ from chatbots or simple LLM calls
  • The ReAct loop — the core pattern behind nearly all production agents
  • How tool calling works at the API level
  • How to design multi-agent workflows for complex tasks
  • What Model Context Protocol (MCP) is and how to use and build MCP servers
  • How to choose between agent frameworks (LangChain, CrewAI, AutoGen) and when to skip them
  • How memory works in agent systems and the different types of memory you can use
  • How to write system prompts designed for agent loops, not single-turn chat
  • How to configure AI coding assistants with CLAUDE.md and the AgentMD pattern

Your First Agent: 30 Lines of Python

Before diving into concepts, here’s a complete, working AI agent you can run right now:

Terminal window
pip install anthropic
export ANTHROPIC_API_KEY="your-api-key"
import anthropic
client = anthropic.Anthropic()
TOOLS = [{
"name": "calculator",
"description": "Evaluate a mathematical expression. Use for any calculation.",
"input_schema": {
"type": "object",
"properties": {
"expression": {
"type": "string",
"description": "A Python math expression, e.g. '2 + 2' or '137 * 89'"
}
},
"required": ["expression"]
}
}]
def calculator(expression: str) -> str:
try:
return str(eval(expression, {"__builtins__": {}}))
except Exception as e:
return f"Error: {e}"
def run_agent(task: str) -> str:
messages = [{"role": "user", "content": task}]
for _ in range(10):
response = client.messages.create(
model="claude-opus-4-6",
max_tokens=1024,
tools=TOOLS,
messages=messages,
)
if response.stop_reason == "end_turn":
return next(b.text for b in response.content if hasattr(b, "text"))
messages.append({"role": "assistant", "content": response.content})
tool_results = []
for block in response.content:
if block.type == "tool_use" and block.name == "calculator":
tool_results.append({
"type": "tool_result",
"tool_use_id": block.id,
"content": calculator(block.input["expression"]),
})
if tool_results:
messages.append({"role": "user", "content": tool_results})
return "Max turns reached"
print(run_agent("What is the compound interest on $10,000 at 7% annually for 20 years?"))

This demonstrates the complete agent loop: send a task, check if the model wants to use a tool, execute the tool, feed the result back, repeat until done. Everything else in this guide builds on this pattern.

How to Use This Guide

Each topic is structured as three layers:

  1. Concept — What is it and why does it matter?
  2. Tutorial — Step-by-step walkthrough
  3. Code — Working examples you can run and adapt

If you’re new to agents, follow the guide in order:

  1. AI Agents — Concepts & Architecture
  2. Agentic Workflows
  3. MCP — Model Context Protocol
  4. Agent Frameworks
  5. Tools, Skills & Memory
  6. Prompt Engineering for Agents

If you’re already familiar with the basics, jump directly to the section you need using the sidebar.

Prerequisites

  • Basic Python knowledge (most examples use Python)
  • Familiarity with REST APIs and JSON
  • An API key for at least one LLM provider (Anthropic, OpenAI, or similar)

To get an Anthropic API key, create an account at console.anthropic.com. The API has pay-as-you-go pricing — running the examples in this guide costs a few cents in API usage.

Key Concepts at a Glance

Before going deeper, here’s a quick orientation to the most important terms:

AI Agent: A system that uses an LLM to reason about a goal and take actions toward it, in a loop. The loop continues until the goal is achieved or a stopping condition is met.

Tool / Function Call: A function that the LLM can invoke. The LLM decides when and how to call a tool; your code executes the call and returns the result.

ReAct: The dominant pattern for AI agents. The model alternates between reasoning (thinking about what to do next) and acting (calling a tool). The name is a portmanteau of Reason + Act.

MCP (Model Context Protocol): An open standard from Anthropic for connecting AI models to tools and data. Lets you write a tool integration once and use it with any MCP-compatible model.

Context Window: The maximum amount of text (measured in tokens) that an LLM can process in a single call. Long-running agents accumulate context that can exceed this limit, requiring active management.

Agentic Workflow: A multi-stage pipeline where AI agents handle different stages. More structured than a single agent, with defined handoffs between stages.

System Prompt: Instructions sent to the model at the start of every conversation. For agents, the system prompt defines the agent’s role, available tools, and decision-making process.

CLAUDE.md / AgentMD: A file placed in a project root that AI coding assistants automatically load. Provides project-specific instructions so the agent can operate within your codebase’s conventions without you having to re-explain them every session.

What Makes a Good AI Agent

AI agents can do things that chatbots can’t: access real-time information, run code, interact with external services, and complete multi-step tasks autonomously. But they can also fail in ways chatbots don’t — getting stuck in loops, misusing tools, accumulating errors across many steps.

Good agents share a few characteristics:

Clear, specific tools: Each tool does one thing well and has a description that tells the model exactly when to use it. Ambiguous or overlapping tools lead to incorrect tool selection.

Explicit stopping conditions: The agent knows when it’s done. Without clear stopping conditions (a specific goal achieved, a maximum turn count, a user approval checkpoint), agents can loop indefinitely.

Failure recovery: What happens when a tool fails? Good agents return informative error messages that allow the model to retry with different arguments or try an alternative approach.

Human checkpoints for irreversible actions: Before sending an email, posting to social media, modifying a production database, or taking any other irreversible action, good agents pause for human confirmation.

Minimal scope: Each agent has access to only the tools it needs. A research agent doesn’t need write access to your database. Minimal access reduces the blast radius of errors.

These principles apply whether you’re building a simple single-step agent or a complex multi-agent pipeline. They’re worth internalizing early, because it’s much easier to build them in from the start than to retrofit them later.

The Ecosystem at a Glance

The AI agent ecosystem is large and evolving quickly. Here’s a map of the major pieces:

Models: Claude (Anthropic), GPT-4o (OpenAI), Gemini (Google). Each has different context windows, capabilities, and pricing. Claude is used throughout this guide.

Frameworks: LangChain (general-purpose, large ecosystem), CrewAI (role-based multi-agent), AutoGen (conversational multi-agent). Detailed comparisons in the Frameworks section.

MCP Servers: Pre-built integrations for GitHub, PostgreSQL, filesystem, Slack, and hundreds more. Detailed reference in MCP Servers.

Tools: Anything you can wrap as a function — web search, code execution, file operations, database queries, API calls. The sky is the limit on what agents can do once you give them the right tools.

Getting Help

If you find an error or outdated information, open an issue at https://github.com/Sero01/ai-agents-guide. Contributions are welcome.

If you’re stuck on a concept, the Concepts & Architecture page often has the foundational explanation that fills in the gap.