# Self-managed agents

> Connect AG-UI agents that you host and secure yourself.

If you host and secure your own AG-UI agent, the frontend can call it directly,
without the CopilotKit [runtime](/angular/langgraph-python/backend/copilot-runtime). Use
`selfManagedAgents` in production. For local development, use
`agents__unsafe_dev_only` in React or `agents` in Angular.

## Production: self-managed agents [#production-self-managed-agents]

`selfManagedAgents` is the supported configuration option for connecting agents you manage
yourself, for example an [`HttpAgent`](/angular/langgraph-python/backend/ag-ui) pointing at an
AG-UI-compatible backend you own and have already secured:

```ts title="src/app/app.config.ts"
import { ApplicationConfig } from "@angular/core";
import { HttpAgent } from "@ag-ui/client";
import { provideCopilotKit } from "@copilotkit/angular";

const supportAgent = new HttpAgent({
  url: "https://agents.example.com/support",
});

export const appConfig: ApplicationConfig = {
  providers: [
    provideCopilotKit({
      selfManagedAgents: { "support-agent": supportAgent },
    }),
  ],
};
```

Each key is the `agentId` that chat components and frontend agent APIs use to
address that agent. Self-managed agents use your transport and your security
model. Because the requests don't pass through the CopilotKit runtime, the
runtime's server-side auth, middleware, and routing do not apply. Your agent
endpoint must [authenticate and authorize every request](/angular/langgraph-python/auth).

Open a chat that uses the `support-agent` agent ID and send a message. The
endpoint at `https://agents.example.com/support` receives the run, and its reply
streams into the chat.

<Callout type="info" title="Part of CopilotKit Intelligence">
  `selfManagedAgents` is part of the CopilotKit Intelligence [Enterprise
  plan](/angular/langgraph-python/intelligence/intelligence-platform). [Talk to an
  engineer](https://copilotkit.ai/talk-to-an-engineer) about licensing for
  production use.
</Callout>

<Callout type="info">
You can combine `selfManagedAgents` with `runtimeUrl`. Runtime-discovered agents
and self-managed agents coexist; address each by its `agentId`.
</Callout>

## Development: local agents [#development-local-agents]

The Angular provider's `agents` option accepts the same shape for local,
in-browser development:

```ts title="src/app/app.config.ts"
import { HttpAgent } from "@ag-ui/client";
import { provideCopilotKit } from "@copilotkit/angular";

const localAgent = new HttpAgent({ url: "http://localhost:8000" });

provideCopilotKit({
  agents: { "my-agent": localAgent },
})
```

Use `agents` only for local development and prototyping. For production,
switch to `selfManagedAgents` after securing the endpoint, or move the agent
behind the [runtime](/angular/langgraph-python/backend/copilot-runtime).

## How they relate [#how-they-relate]

Both sources feed the same client-side agent registry. When both are supplied
they are merged, and **`selfManagedAgents` wins on a key collision**:

```ts
// effective agents ≈ { ...agents, ...selfManagedAgents }
```

If at least one agent is registered through either provider option, the
frontend configuration check passes.

| | `selfManagedAgents` | Local agents |
|---|---|---|
| **Intended for** | Production, agents you manage | Local dev / prototyping |
| **Auth** | Your responsibility | Your responsibility |
| **Runtime middleware / routing** | Not applied | Not applied |
| **Precedence on collision** | Wins | Overridden by `selfManagedAgents` |
