Skip to main content
Every PraisonAI agent has the same core structure. Understanding it helps you build better agents.

The 4 Core Components

1. Instructions

What the agent does and how it behaves

2. LLM (Brain)

The AI model that powers thinking

3. Tools

Functions the agent can call

4. Memory

Remembers past conversations

Building an Agent

1

Instructions - Define Purpose

from praisonaiagents import Agent

agent = Agent(
    instructions="You are a helpful coding assistant"
)
2

LLM - Choose the Brain

agent = Agent(
    instructions="You are a helpful assistant",
    llm="gpt-4o"  # Or "claude-3", "gemini-pro", etc.
)
3

Tools - Add Capabilities

def calculate(expression: str) -> str:
    """Calculate a math expression"""
    return str(eval(expression))

agent = Agent(
    instructions="You help with math",
    tools=[calculate]
)
4

Memory - Remember Context

agent = Agent(
    instructions="You are a personal assistant",
    memory=True  # Remember conversations
)

Complete Example

from praisonaiagents import Agent

def search_web(query: str) -> str:
    """Search the web"""
    return f"Results for: {query}"

# Full agent with all components
agent = Agent(
    name="ResearchAssistant",
    instructions="You research topics and provide summaries",
    llm="gpt-4o",
    tools=[search_web],
    memory=True
)

agent.start("Research the latest AI trends")

The Agent Loop

Every agent follows this cycle:
StepWhat Happens
ReceiveAgent gets your message
ThinkLLM processes and plans
ActUses tools if needed
RespondReturns the answer

Multi-Agent Architecture

Multiple agents can work together:
from praisonaiagents import Agent, AgentTeam

researcher = Agent(instructions="Research topics")
writer = Agent(instructions="Write content")
editor = Agent(instructions="Edit and polish")

team = AgentTeam(agents=[researcher, writer, editor])
team.start()

Key Takeaways

Begin with just instructions - add tools and memory later
GPT-4o for complex tasks, GPT-4o-mini for simple ones
Any Python function can become a tool
Enable memory for multi-turn conversations

Next: Agent Instructions

Learn how to write effective instructions for your agents.