Agent Architecture
Understanding how AI agents are structured
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. ToolsFunctions the agent can call
4. MemoryRemembers past conversations
Building an Agent
- Instructions – Define Purpose
python from praisonaiagents import Agent agent = Agent( instructions="You are a helpful coding assistant" ) - LLM – Choose the Brain
python agent = Agent( instructions="You are a helpful assistant", llm="gpt-4o" # Or "claude-3", "gemini-pro", etc. ) - Tools – Add Capabilities
python def calculate(expression: str) -> str: """Calculate a math expression""" return str(eval(expression)) agent = Agent( instructions="You help with math", tools=[calculate] ) - Memory – Remember Context
python 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:
| Step | What Happens |
|---|---|
| Receive | Agent gets your message |
| Think | LLM processes and plans |
| Act | Uses tools if needed |
| Respond | Returns 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
Start Simple
Begin with just instructions – add tools and memory later
Choose the Right LLM
GPT-4o for complex tasks, GPT-4o-mini for simple ones
Tools Extend Capabilities
Any Python function can become a tool
Memory Enables Context
Enable memory for multi-turn conversations
Next: Agent Instructions
Learn how to write effective instructions for your agents.