External CLI integrations enable you to drive external AI coding tools from PraisonAI agents, with Claude Code as the flagship example.Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Quick Start
How It Works
The integration builds CLI arguments dynamically per call, with no instance state mutated during execution.Stateless Session Management
| Old (removed / ignored) | New explicit parameter |
|---|---|
self._session_active = True (auto) | continue_session=True per call |
self.output_format mutated during stream() | output_format="stream-json" passed per call |
integration.reset_session() | No longer needed — deprecated no-op |
Because state is no longer shared on the instance, a single
ClaudeCodeIntegration is safe to call concurrently from multiple tasks / threads.CLI: Manager Delegation (Default)
PraisonAI CLI offers two execution modes for external agents, providing flexibility between automated reasoning and direct execution.| Mode | Flag | Behaviour | Best for |
|---|---|---|---|
| Manager delegation (default) | --external-agent X | Manager Agent wraps the CLI as a tool, reasons, then calls it | Multi-step tasks, planning, aggregation |
| Direct proxy | --external-agent X --external-agent-direct | Pass-through — CLI runs the prompt verbatim | Fast single-shot calls, scripting, when you don’t want a manager LLM |
Configuration Options
| Option | Type | Default | Where | Description |
|---|---|---|---|---|
workspace | str | "." | constructor | Working directory passed to the CLI |
timeout | int | 300 | constructor | Per-call timeout (seconds) |
output_format | str | "json" | constructor or per-call | "text" | "json" | "stream-json" |
use_sdk | bool | False (True if SDK available) | constructor | Use the Claude Code SDK when installed, otherwise fall back to subprocess |
model | str | None | None | constructor | Passed through to the CLI via --model |
continue_session | bool | False | per-call | Adds --continue to the CLI invocation |
skip_permissions | bool | True | constructor | Skip permission prompts with --dangerously-skip-permissions |
system_prompt | str | None | None | constructor | Custom system prompt to append |
allowed_tools | List[str] | None | None | constructor | List of allowed tools (e.g., [“Read”, “Write”, “Bash”]) |
disallowed_tools | List[str] | None | None | constructor | List of disallowed tools |
Registry
TheExternalAgentRegistry manages all available CLI integrations using a thread-safe singleton pattern:
_availability_cache lock to ensure is_available() checks are safe from concurrent access.
Prerequisites
Theclaude CLI must be available on PATH or the Claude Code SDK must be installed if use_sdk=True. The integration performs a cached, thread-safe shutil.which(...) check via is_available().
Decision Flow
Best Practices
Always pass continue_session=True explicitly
Always pass continue_session=True explicitly
Don’t rely on instance state for session continuation. Always be explicit about when you want to continue a previous session.
Set output_format per call or once in constructor
Set output_format per call or once in constructor
Do not mutate the
integration.output_format attribute between calls. Use the per-call parameter or set it once during initialization.Remove reset_session() calls
Remove reset_session() calls
The
reset_session() method is now a no-op. Remove these calls from your code as they serve no purpose.Safe for concurrent use
Safe for concurrent use
A single
ClaudeCodeIntegration instance can be shared across concurrent tasks safely since no instance state is mutated during calls.Using from PraisonAI UI
Related
Persistence & Concurrency
Learn about thread-safe persistence features
Agent Tools
Using integrations as agent tools

