Skip to main content

What are General AI Agents?

General AI Agents are the core building blocks of the PandaAGI SDK. They are autonomous AI entities that can understand natural language, make decisions, use tools, and interact with their environment to accomplish tasks. PandaAGI general AI agents consist of four key components:
  • WebSocket Communication: Real-time bidirectional connection with the AGI backend server
  • Tool Handlers: Pluggable modules that provide different capabilities and tool access
  • Environment Integration: Isolated workspace for secure file and system operations
  • Event Streaming: Real-time transmission of agent thoughts, actions, and results

Creating General AI Agents

Basic General AI Agent

The simplest way to create an agent:

General AI Agent with Custom Configuration

For more control over agent behavior:

Models

PandaAGI offers two powerful agentic models to suit your needs. You can specify the model using the model parameter in the Agent constructor. By default, the SDK uses annie-pro. You can select annie-lite like this:

Using Environment Variables

Set your API key in environment variables:

How do general AI agents work?

Understanding how agents work internally:
1

Initialization

General AI agent initializes WebSocket client, event manager, and tool handlers
2

Connection

General AI agent establishes WebSocket connection and waits for initialization
3

Request Processing

General AI agent sends query and begins streaming events in real-time
4

Event Streaming

General AI agent streams thoughts, tool usage, and results as they happen
5

Completion

General AI agent signals task completion and can handle new requests

How to configure general AI agents?

Environment Setup

Configure the agent’s workspace:

Tool Handlers

Customize tool handling behavior:

Conversation Context

Enable follow-up questions and maintain context across multiple requests:
Key Benefits:
  • Context Retention: Agent remembers previous questions and answers
  • Natural Conversations: Ask follow-up questions without repeating context
  • Session Persistence: Maintain conversations across multiple script runs
Important: The conversation_id must be a valid UUID4 string generated with str(uuid.uuid4()). This ensures proper conversation tracking and prevents conflicts.

Multi-Turn Conversations

Build complex interactions with follow-up questions:

Available Event Types

General AI agents emit various types of events during execution. For complete details on all events, see the Events documentation.

File System Integration

General AI agents can work with files in their environment:

Cross-Session Persistence

Maintain conversations across different script executions:

Resource Management

Properly manage connections and resources:

Workspace Isolation

Set up appropriate workspace environments for security:

Next Steps

Events

Learn about agent event streaming in detail

Environments

Understand agent workspace environments