# Claude Managed Agents

Render a Claude Managed Agents session and show when it needs tool confirmation.

## Load events from a session

Install the SDK on your server.

```bash
npm install @anthropic-ai/sdk@1.3.0
```

Managed Agents uses a beta API. Configure the required beta header and workspace on the server. Authenticate requests there and send only the session events the browser is allowed to see.

```tsx
import Anthropic from "@anthropic-ai/sdk";
export async function readSession(client: Anthropic, sessionId: string) {
  const events = [];
  for await (const event of client.beta.sessions.events.list(sessionId, { order: "asc", betas: ["managed-agents-2026-04-01"] })) {
    events.push(event);
  }
  return events;
}
export function confirmTool(client: Anthropic, sessionId: string, toolUseId: string, approved: boolean) {
  return client.beta.sessions.events.send(sessionId, {
    betas: ["managed-agents-2026-04-01"],
    events: [{ type: "user.tool_confirmation", tool_use_id: toolUseId, result: approved ? "allow" : "deny" }],
  });
}

```

```tsx
import { normalizeManagedAgentEvents } from "@collectivecreation/ghost-ui/chat-normalizers";
import { Message, MessageBody } from "@collectivecreation/ghost-ui/components/message";
import { MessageParts } from "@collectivecreation/ghost-ui/components/message-parts";
export function ManagedTranscript({ events }: { events: readonly unknown[] }) {
  const messages = normalizeManagedAgentEvents(events);
  return <>{messages.map(message => <Message key={message.id} actor={message.actor}><MessageBody>
    <MessageParts parts={message.parts} />
  </MessageBody></Message>)}</>;
}

```

events.list auto-paginates; preserve ascending server order. Live events.stream can feed the same application log and projection. Own the replay/live handoff, reconnect and event-ID deduplication in one server/session owner; the stream endpoint does not provide an invented Ghost replay cursor. Use replaceChatRecordsById only after your owner has established event ordering.

## Approval is not execution

When session.status_idle reports requires_action, check which event IDs are blocked. A built-in or MCP tool can request user.tool_confirmation. An accepted confirmation becomes approval-resolved. Wait for the actual tool result before showing output-ready.

An agent.custom_tool_use requires a user.custom_tool_result with custom_tool_use_id and result content after caller-owned execution. Ghost exposes this as managed-client-tool-request data, not boolean approval. Validate the request and authorize execution server-side. Missing/unmatched results stay explicit.

## Preview and failure boundaries

Buffered facts are authoritative. Best-effort event_start/event_delta previews remain explicit data and are superseded by buffered messages; they are not durable transcript records or automatically displayed reasoning. Native thinking is a progress signal, not text to reveal. Use a validated custom renderer if your product needs preview data.

See [Managed Agents documentation](https://platform.claude.com/docs/en/managed-agents/overview) for sessions, event streaming, permissions and custom tools. For React controls, compose [Tool](/ai-elements/tool) with your server command and current request identity; the normalizer does not execute it or supply a hidden transport.
