Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/praisonai-agents/praisonaiagents/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ def __init__(
approval: Optional[Union[bool, str, Dict[str, Any], 'ApprovalConfig', 'ApprovalProtocol']] = None,
tool_timeout: Optional[int] = None, # P8/G11: Timeout in seconds for each tool call
learn: Optional[Union[bool, str, Dict[str, Any], 'LearnConfig']] = None, # Continuous learning (peer to memory)
backend: Optional[Any] = None, # External managed agent backend (e.g., ManagedAgentIntegration)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

backend is only stored, never used.

These changes add a public backend option and document delegated execution, but none of the execution paths in this file consult self.backend. Agent(backend=managed) therefore still runs locally, so the feature is effectively unimplemented.

Also applies to: 578-582, 1807-1808

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/praisonai-agents/praisonaiagents/agent/agent.py` at line 490, The new
backend parameter is stored but never consulted; update the agent execution
paths to delegate to the external backend when present. Concretely, in the Agent
class use the stored self.backend in the main run/execute flow (e.g., Agent.run
and the agent execution entrypoints such as Agent.execute or internal methods
like Agent._execute_action / Agent._execute) to call into the backend (e.g.,
backend.execute or a documented delegate method) and return its result, falling
back to the current local implementation when self.backend is None; make the
delegation consistent wherever execution is performed (the places flagged around
the constructor and the other execution entrypoints referenced) and ensure
errors from the backend are propagated or translated the same way as local
execution.

):
"""Initialize an Agent instance.

Expand Down Expand Up @@ -574,6 +575,11 @@ def __init__(
- LearnConfig: Custom configuration
Learning is a first-class citizen, peer to memory. It captures patterns,
preferences, and insights from interactions to improve future responses.
backend: External managed agent backend for hybrid execution. Accepts:
- ManagedAgentIntegration: External managed agent service
- None: Use local execution (default)
When provided, agent can delegate execution to managed infrastructure
for long-running tasks or when local resources are constrained.

Raises:
ValueError: If all of name, role, goal, backstory, and instructions are None.
Expand Down Expand Up @@ -1798,6 +1804,9 @@ def __init__(
self._output_file = output_file if _output_config else None
self._output_template = output_template if _output_config else None

# Backend - external managed agent backend for hybrid execution
self.backend = backend
Comment on lines +1807 to +1808
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 backend is stored but never consulted during execution

The backend attribute is stored here but there is no code in the agent's start(), chat(), or any execution path that checks self.backend and delegates execution to it. As a result, even when a ManagedAgentIntegration is passed, the agent always executes locally. The usage example in the PR description (agent.start("Create a FastAPI app")) will silently ignore the backend.

The integration is incomplete until the execution path (e.g., chat() or start()) checks if self.backend is not None: return await self.backend.execute(prompt) (or similar) to delegate accordingly.

Comment on lines +1807 to +1808
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new backend parameter is stored on the Agent instance, but it is never referenced elsewhere in agent.py (search shows only this assignment). As-is, passing a managed backend won’t change execution behavior despite the docstring describing “hybrid execution”. Either wire self.backend into the execution/chat flow (delegating to the managed backend), or remove/soft-launch the parameter + docs until it has an effect.

Copilot uses AI. Check for mistakes.

# Telemetry - lazy initialized via property for performance
self.__telemetry = None
self.__telemetry_initialized = False
Expand Down
16 changes: 12 additions & 4 deletions src/praisonai/praisonai/integrations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
"""
PraisonAI Integrations - External CLI tool integrations.
PraisonAI Integrations - External CLI tool and managed agent integrations.

This module provides integrations with external AI coding CLI tools:
This module provides integrations with external AI coding tools:
- Claude Code CLI
- Gemini CLI
- OpenAI Codex CLI
- Cursor CLI
- Managed Agent Backends (Anthropic Managed Agents API)

All integrations use lazy loading to avoid performance impact.

Usage:
from praisonai.integrations import ClaudeCodeIntegration, GeminiCLIIntegration
from praisonai.integrations import ClaudeCodeIntegration, ManagedAgentIntegration

# Create integration
# CLI tool integration
claude = ClaudeCodeIntegration(workspace="/path/to/project")

# Managed agent integration
managed = ManagedAgentIntegration(provider="anthropic", api_key="...")

# Use as agent tool
tool = claude.as_tool()

Expand All @@ -29,6 +33,7 @@
'GeminiCLIIntegration',
'CodexCLIIntegration',
'CursorCLIIntegration',
'ManagedAgentIntegration',
'get_available_integrations',
]

Expand All @@ -50,6 +55,9 @@ def __getattr__(name):
elif name == 'CursorCLIIntegration':
from .cursor_cli import CursorCLIIntegration
return CursorCLIIntegration
elif name == 'ManagedAgentIntegration':
from .managed_agents import ManagedAgentIntegration
return ManagedAgentIntegration
elif name == 'get_available_integrations':
from .base import get_available_integrations
return get_available_integrations
Expand Down
Loading