# Connect AG-UI, AgentCore, and Kam State

Kam State adds versioned application state to Amazon Bedrock AgentCore.

Connect an AG-UI server hosted by Amazon Bedrock AgentCore to the Kam State SDK through application-owned calls. Keep interface events, execution, and durable result evidence distinct.

> Keep exact recorded results available to an AgentCore application while AG-UI projects the authorized evidence into its interface.

Status: Implemented in source. Prelaunch; not a live service guarantee.
Kam integration pattern using existing private SDK operations. No packaged Kam AG-UI adapter, automatic capture into Kam, hosted Kam endpoint, or live Kam qualification is established by this guide.

Backend review: 2026-10-14.
Backend source: e16b81b4a637acec91f3aed8a71cf5b0f42f0c19.
Native toolkit: merged in PR #176, reviewed at e16b81b4a637acec91f3aed8a71cf5b0f42f0c19.
HTML: /docs/ag-ui-agentcore

## In short

AgentCore Runtime supports AG-UI servers. Your application uses the Kam SDK to record supported results and read exact retained revisions, then maps authorized evidence to interface state. This guide covers the Kam connection, including retries and reconnects; it does not install an automatic Kam adapter.

**Available today:** AWS supports deploying AG-UI servers in AgentCore Runtime. Kam's private 0.49.0 artifact provides the documented SDK methods; the live connection between Kam and your application needs separate qualification.

## Connect the interface to recorded evidence

- **Run in AgentCore** — Your application controls the agent and streams AG-UI events.
- **Record with the Kam SDK** — Persist supported declared results through an authorized server connection.
- **Project exact records** — Read retained revisions and map permitted fields into the interface.

## Give each layer one responsibility

1. **Interface and AG-UI** — CopilotKit or your own client renders messages and state. AG-UI carries run, message, tool, snapshot and delta events between the interface and backend.

2. **Amazon Bedrock AgentCore** — Hosts your AG-UI server and handles runtime authentication, session isolation and scaling. Your application and framework control model calls, tools and business decisions. Memory recall is a separate configured service.

3. **Your server-side adapter** — Authenticate the caller, resolve authorized scope, validate events, and decide which supported facts to record or expose. Keep service credentials on the trusted server.

4. **Kam State** — Record accepted results, preserve exact revisions and fixed membership, and return scoped evidence. Kam does not execute the agent or infer that an external action succeeded.

## Prepare the two connections separately

Obtain the approved @kam-ai/agentcore-history-sdk artifact and its provenance before running the SDK. The bundled artifact is 0.49.0; it is not published to npm. An authorized Kam endpoint, principal and server-owned tenant binding are separate requirements.

Deploy your AG-UI server to AgentCore Runtime using AWS’s guide, including its protocol and authorization setup. Runtime supports HTTP/SSE and WebSocket connections. Installing the Kam SDK does not create that runtime, grant IAM permissions, configure Memory, or register Gateway tools.

[SDK prerequisites and examples](/developers#before-you-start)

[AWS: deploy AG-UI servers in AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-agui.html)

[AgentCore AG-UI protocol contract](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-agui-protocol-contract.html)

## Record a declared result after application execution

Your application executes the task and determines its declared outcome. Bind state({ subjectId, type }), call record() with a stable result identity, and retain the returned ID and revision. Only supported success or failure outcomes belong in this contract; pending, cancelled and unknown are not converted into failure.

A RUN_FINISHED event describes the AG-UI run lifecycle. It is not a Kam acceptance receipt or proof that every external effect completed. Store only the facts your application can attest, with exact references where the selected contract supports them.

[Record, retry, correct, and read](/developers#integration)

[SDK integration contract](/docs/integrate)

## Project authorized evidence into the interface

For a known result, use byIds() with its exact ID and revision. To browse History, call allIds() for a bounded UTC-day page, preserve its generation, and pass the returned references to byIds(). Carry the same generation and returned cursor through subsequent pages.

Your adapter selects which authorized fields the interface may receive. AG-UI STATE_SNAPSHOT establishes the interface state; STATE_DELTA applies ordered JSON Patch changes. These protocol events do not themselves establish Kam persistence or a durable-history receipt.

After a reconnect, your application can re-read the required retained records and rebuild its projection. Preserve unavailable or expired references explicitly. This does not resume a whole conversation, rerun a tool, or establish that a model used those records.

[Read a pinned collection](/developers#sdk)

[Exact History contract](/docs/history)

[AG-UI state synchronization](https://docs.ag-ui.com/concepts/state)

## Keep protocol IDs and record identity distinct

1. **AG-UI threadId and runId** — Identify the application interaction. They do not grant tenant access or become a Kam revision automatically.

2. **AgentCore session ID** — Selects the runtime session. Do not infer durable History membership or authorization from it.

3. **Kam subjectId and type** — Select the application-defined scope within the server-authorized tenant. Your backend owns the explicit mapping.

4. **Outcome ID, revision, and generation** — Name a stored result, its exact version, and a fixed History list. Preserve the returned references rather than constructing them from UI events.

## Design the failure path before adding more workflows

1. **A record response is lost** — Preserve the original record identity, revision and payload. A supported exact retry can return retained acceptance evidence; it never reruns the original tool effect.

2. **The stream disconnects** — Track interface connection, runtime progress and State acceptance independently. A closed connection does not prove that a write failed or that work was cancelled.

3. **An input changes or expires** — Inspect the exact retained input or report the gap. Your application decides whether the result still applies and whether to refresh it.

[Handle result-write retries](/docs/agent-result-retries)

[Review changed inputs](/docs/changed-agent-inputs)

[State, Memory, and Context](/architecture#long-horizon)

## Qualify the application you actually connect

SDK 0.49.0 has offline artifact evidence. The broader backend capability review remains pinned to 2026-10-14 and SDK 0.40.0; these are different checkpoints.

Evaluate the same approved SDK and endpoint with your adapter, authority, record mapping, retry policy and retention requirements. Verify runtime execution, State acceptance, readback and external effects separately. Public examples do not prove this end-to-end connection.

[Qualification evidence](/docs/qualification)

[Scope an evaluation](/evaluation)
