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 with a thread-safe registry pattern with lazy module-level default. You can construct your own ExternalAgentRegistry() for test isolation or multi-tenant runs:
As of PraisonAI PR #1849,
ExternalAgentRegistry.create() raises ValueError for unknown integrations (parent registry contract). Use try_create() for the previous “return None on failure” behaviour. The module-level helper create_integration(name, **kwargs) already calls try_create() under the hood and still returns None on failure — no migration needed for code that uses it.get_registry(), register_integration(), create_integration(), and get_available_integrations() are still exported and still work — they now delegate to get_default_registry(). Backward-compat code does not need to change.
Invalidating the availability cache
BaseCLIIntegration caches the result of shutil.which(cli_command) for each CLI. If a CLI is installed/uninstalled mid-run (e.g. in tests, or after a setup step), invalidate the cache:
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

