Skip to content

Claude Managed Agents Integration

Pisama integrates with Claude Managed Agents to monitor agent sessions and detect failure modes in Anthropic-hosted agent systems.

How the integration works

Managed Agents runs on Anthropic's infrastructure and does not push webhooks to external systems. Pisama connects to the Anthropic API to pull session events via the /sync endpoint, then runs its detection pipeline.

Primary path (recommended): Register your Anthropic API connection, then call POST /sync to pull sessions and run detection.

Secondary path: Build your own bridge that streams from Anthropic's SSE endpoint and posts pre-processed session data to Pisama's /webhook endpoint.

Setup

1. Get a Bearer Token

curl -X POST https://api.pisama.ai/api/v1/auth/token \
  -H "Content-Type: application/json" \
  -d '{"api_key": "pisama_your_api_key_here"}'
export TOKEN="<access_token>"

2. Register a Connection

curl -X POST https://api.pisama.ai/api/v1/managed-agents/connections \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "production",
    "api_key": "<your_anthropic_api_key>",
    "organization_id": "<your_anthropic_org_id>"
  }'

3. Register Agents

Register each agent you want to monitor. The mcp_servers and allowed_hosts fields enable platform-specific detection.

curl -X POST https://api.pisama.ai/api/v1/managed-agents/agents \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "connection_id": "<connection_id>",
    "agent_id": "<anthropic_agent_id>",
    "agent_name": "My Research Agent",
    "mcp_servers": ["linear", "github"],
    "allowed_hosts": ["api.github.com", "*.linear.app"]
  }'

4. Sync Sessions (Pull Model)

Pull recent sessions from the Anthropic API. This fetches session events, creates Pisama traces, and runs detection.

curl -X POST https://api.pisama.ai/api/v1/managed-agents/sync \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "connection_id": "<connection_id>",
    "limit": 20
  }'

Set up a cron job to sync periodically:

*/15 * * * * curl -sS -X POST https://api.pisama.ai/api/v1/managed-agents/sync \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"connection_id": "<id>", "limit": 20}' >> /tmp/pisama-sync.log 2>&1

5. Discover Agents

List all agents from the Anthropic API for registration:

curl -X POST https://api.pisama.ai/api/v1/managed-agents/discover \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"connection_id": "<connection_id>"}'

Event Model

Pisama understands the real Managed Agents event types:

Event Type Category What Pisama analyzes
user.message User input Content for hallucination, injection detection
agent.message Agent output Content for drift, hallucination, loop detection
agent.thinking Reasoning Thinking content for coherence analysis
agent.tool_use Built-in tool Tool call patterns for loop, stall detection
agent.tool_result Tool output Error rates, result quality
agent.mcp_tool_use MCP tool MCP server scope, retry patterns
agent.mcp_tool_result MCP result MCP failure rates, error patterns
agent.custom_tool_use Custom tool Custom tool call patterns
span.model_request_end Telemetry Token usage, cost aggregation
session.status_* Lifecycle Status transition validation
session.error Errors Infrastructure error tracking
agent.thread_message_* Multi-agent Coordination analysis (research preview)

Detection Capabilities

Managed Agents-Specific Detectors

Detector Failure Mode Description
Session Stall F13 (Timeout) Large event gaps, sessions stuck without progress
MCP Failure F14 (Tool Failure) MCP tool errors, retry patterns, high error rates
Cost Overrun F16 (Budget) Token aggregation from span events, budget thresholds
Session Corruption F2 (State) Invalid status transitions, timestamp regressions, session errors
Tool Permission F5 (Security) MCP tool calls to unregistered servers
Environment Escape F5 (Security) Blocked host access attempts (infrastructure prevents the action; this detects the intent)

Core Detectors (Also Applied)

All 20 core detectors run on Managed Agents session content, including loop detection, hallucination, persona drift, coordination failures, and more.

OTEL Integration

If sessions emit OpenTelemetry spans, Pisama auto-detects them:

OTEL Attribute Prefix Framework
claude.managed_agents.* managed_agents
managed_agents.agent.id Agent identifier
managed_agents.agent.name Agent display name

API Endpoints

Method Path Description
POST /managed-agents/sync Primary: Pull sessions from Anthropic API
POST /managed-agents/discover Discover agents from Anthropic API
POST /managed-agents/webhook Receive pre-processed session data
POST /managed-agents/connections Register a connection
GET /managed-agents/connections List connections
POST /managed-agents/agents Register an agent
GET /managed-agents/agents List agents
GET /managed-agents/stream SSE for real-time Pisama events

Beta Notes

Claude Managed Agents is in public beta (managed-agents-2026-04-01). Multi-agent threads are in research preview. Pisama pins the beta version and gracefully handles unknown event types.