Skip to content

Feature: External Managed Agent Backends #1358

@MervinPraison

Description

@MervinPraison

Feature: External Managed Agent Backends

Summary

Support external managed agent infrastructures as execution backends, starting with Anthropic's Managed Agents API. This follows the existing BaseCLIIntegration pattern in praisonai/integrations/.

Motivation

  • Enable long-running tasks in managed infrastructure without local resource constraints
  • Provide hybrid execution: local agents can delegate to managed backends
  • Support use cases requiring secure sandboxed environments

Proposed Implementation

Location

praisonai/integrations/managed_agents.py following existing pattern:

praisonai/integrations/
├── base.py              # Existing BaseCLIIntegration
├── claude_code.py       # Existing
├── managed_agents.py    # NEW - Generic managed agent backend
└── __init__.py

Core Design

class ManagedAgentIntegration(BaseCLIIntegration):
    """Generic integration for managed agent APIs."""
    
    def __init__(
        self,
        provider: str,  # "anthropic", etc.
        api_key: str,
        config: dict
    ):
        self.provider = provider
        self.client = self._create_client(provider, api_key)
        self.config = config
    
    async def execute(self, agent_id: str, environment_id: str, prompt: str) -> str:
        """Execute agent in managed infrastructure."""
        session = await self.client.sessions.create(
            agent=agent_id,
            environment_id=environment_id
        )
        
        await self.client.sessions.events.send(
            session.id,
            events=[{"type": "user.message", "content": prompt}]
        )
        
        return await self._collect_response(session.id)

Integration with PraisonAI Agent

from praisonai import Agent
from praisonai.integrations import ManagedAgentIntegration

# Create managed backend
managed = ManagedAgentIntegration(
    provider="anthropic",
    api_key="...",
    config={"model": "claude-sonnet-4-6"}
)

# Agent uses managed backend
agent = Agent(
    name="coder",
    instructions="You are a coding assistant.",
    backend=managed  # New: backend parameter
)

result = agent.start("Create a FastAPI app")

Minimal Viable Scope

  1. One file: integrations/managed_agents.py (~300 lines)
  2. One protocol: ManagedBackendProtocol in core SDK
  3. One config field: Agent(backend=...) parameter
  4. Zero new dependencies: Use existing aiohttp, pydantic

Reuses Existing Components

Feature Already Exists Use Via
MCP servers mcp/ module Passthrough to managed backend
Skills skills/ module SKILL.md compatible
Tool execution tools/ module Local tools for custom tool types
Event streaming EventBus Bridge SSE to events
CLI pattern BaseCLIIntegration Extend base class

API Mapping (Anthropic as reference)

Endpoint Purpose
POST /v1/agents Create agent config
POST /v1/environments Create container env
POST /v1/sessions Start execution
POST /v1/sessions/{id}/events Send messages
GET /v1/sessions/{id}/stream SSE event stream

Tool Mapping

Managed agent built-in tools map to PraisonAI tools:

  • bashexecute_command
  • read/write/editread_file/write_file/apply_diff
  • glob/greplist_files/search_file
  • web_fetch/searchweb_fetch/search_web

CLI Usage (Optional Phase 2)

# If we add CLI later
praisonai run agents.yaml --backend managed --provider anthropic

Timeline

  • Week 1: ManagedAgentIntegration class, Anthropic provider
  • Week 2: Agent backend integration, tests
  • Total: ~400 lines, 2 weeks

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    claudeAuto-trigger Claude analysisdocumentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions