Skip to main content

External Agents

PraisonAI provides seamless integration with external AI coding CLI tools, allowing you to use Claude Code, Gemini CLI, Codex CLI, and Cursor CLI as agent tools.

Built-in Integrations

These ship with PraisonAI. --external-agent and ExternalAgentsHandler.list_integrations() return these built-ins plus any registered plugins — the set is registry-driven, not fixed. See Register a custom external agent.

Installation

The integrations are included with PraisonAI:
You’ll also need to install the respective CLI tools:

Quick Start

Python API

CLI Usage

As Agent Tools

As a native async agent tool

Preferred when the agent runs on agent.astart(...) (or any async entrypoint) — the tool is awaited directly on the running loop with no thread hop.
as_async_tool() was added in PraisonAI PR #4022; as_tool() still works and is now also safe to call from inside an async agent runtime.

CLI Usage: Manager Delegation vs Direct Proxy

PraisonAI now offers two modes for external CLI integration, balancing power and simplicity.

Manager Delegation (Default)

When using --external-agent, a manager Agent wraps the external CLI as a subagent tool, providing reasoning and planning capabilities.
When to use manager delegation:
  • Multi-step tasks requiring planning
  • Need reasoning across multiple tools
  • Want aggregated responses
  • Complex workflows with decision-making
Manager LLM: Defaults to gpt-4o-mini, configurable via --llm or MODEL_NAME environment variable.

Direct Proxy (Escape Hatch)

Use --external-agent-direct for pass-through behavior — fastest execution with no manager overhead.
When to use direct proxy:
  • Single-shot calls
  • Scripting scenarios
  • Fastest execution needed
  • No manager LLM overhead wanted

Environment Variables

Set the appropriate API keys for each integration:

ExternalAgentsHandler

The ExternalAgentsHandler provides a unified interface for managing external integrations:
On a mixed-version install — a newer praisonai-code against a praisonai wrapper predating external_agent_catalogcheck_dependencies() returns (False, "…too old…") instead of passing and then yielding an empty catalog:
Three states to tell apart:

Performance

All integrations are designed with zero performance impact:

Lazy Loading

Integrations are only imported when used:

Availability Caching

CLI availability checks are cached at the class level:

Streaming

All integrations support streaming output:

Error Handling

The CLI execution path distinguishes an unknown name (ValueError) from a version-skewed install (RuntimeError):

Using from PraisonAI UI

Instead of writing Python code, you can enable external agents directly from any PraisonAI UI by flipping toggles in the interface. See External Agents in UI for complete documentation on UI-based external agent management.

Next Steps

Claude Code

Detailed Claude Code integration guide

Gemini CLI

Detailed Gemini CLI integration guide

Codex CLI

Detailed Codex CLI integration guide

Cursor CLI

Detailed Cursor CLI integration guide