Claude Managed Agents Sse Demo banner
cognimata cognimata

Claude Managed Agents Sse Demo

Development community

Description

A stdlib-only Python CLI that parses and pretty-prints Server-Sent Events from Anthropic's Claude Managed Agents public-beta API (managed-agents-2026-04-01), with a bundled offline fixture and an optional live streaming mode.

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

claude-managed-agents-sse-demo

A tiny Python CLI that parses Server-Sent Events from Anthropic's **Claude Managed Agents** public-beta API (launched April 2026, beta header `managed-agents-2026-04-01`) into typed Python dataclasses and pretty-prints an agent session.

Runs **fully offline** against a bundled fixture — no API key, no install. An optional live mode streams real events if you have an API key and beta access.

Why

Claude Managed Agents shipped a managed harness for running Claude as an autonomous agent: secure sandboxed containers, long-running sessions, built-in tools (bash, file ops, web search), and a server-sent-event stream you read with `GET /v1/sessions/{id}/stream`. The wire format is small but lightly documented. This repo is a one-sit-read reference you can copy and extend: dataclasses that mirror the beta event schema, a tolerant SSE parser (ignores comments, buffers multi-line `data:` fields, drops malformed JSON), and a colorized terminal renderer.

Quickstart

python3 -m cma_sse replay fixtures/fibonacci.sse

That's it — the replay path is stdlib-only. Expected output (colors elided):

-- session: running --
I'll create a Python script that generates the first 20 Fibonacci numbers and saves them to fibonacci.txt.
[tool] write  {"path": "fibonacci.py", "content": "a,b=0,1 ..."}
[tool-ok] Wrote fibonacci.py (96 bytes)
[tool] bash  {"command": "python fibonacci.py && wc -l fibonacci.txt"}
[tool-ok] 20 fibonacci.txt
...
-- session: idle --

{
  "events": 10,
  "by_type": { "session.status": 2, "agent.message": 2, "agent.tool_use": 3, "agent.tool_result": 3 }
}

Optional — stream a live session (you must have already created an agent, environment, and session per the [quickstart](https://platform.claude.com/docs/en/managed-agents/quickstart)):

pip install -r requirements.txt
export ANTHROPIC_API_KEY=...
python3 -m cma_sse live --session-id sess_... --prompt "Say hi"

Event model

| Wire `type`