AWS AgentCore

Add a frontend to your AWS AgentCore agents with CopilotKit.

AWS Bedrock AgentCore gives you a secure, serverless runtime for deploying AG-UI agents at scale. It handles auth, session isolation, and infrastructure. CopilotKit gives those agents a chat UI, shared state, and generative UI in your React or Angular app.

How it works

The two connect through CopilotKit Runtime, a lightweight server-side layer that sits between your browser and AgentCore. This is the same runtime that every CopilotKit agent uses. For AgentCore, it must run on the server. Browsers cannot sign AgentCore requests with SigV4 or OAuth2.

Browser → CopilotKit Runtime → AgentCore Runtime → your agent

What you get

  • Chat UI: prebuilt chat interface, or headless APIs to build your own
  • Shared state: bidirectional sync between agent state and your application UI
  • Generative UI: render custom components from tool calls in real time
  • Human-in-the-loop: let users review, approve, or redirect agent actions
  • AgentCore memory: conversation history persists across sessions via AgentCore's memory layer

Quickstart

AWS CLI required

Both paths below require AWS credentials configured locally. If you haven't done this yet, follow the AWS CLI getting started guide before continuing.

Choose your starting point

Start fresh with our CLI, or connect CopilotKit to an agent you've already deployed on AgentCore.

Run the CLI

npx copilotkit@latest create -f agentcore-langgraph

The CLI downloads the full AgentCore template and sets up config.yaml for you.

Configure

Open config.yaml and set your details:

config.yaml
stack_name_base: my-agentcore-app   # prefix for all AWS resources (max 35 chars)
admin_user_email: you@example.com   # where your Cognito invite will be sent

Then create the .env file in the project root:

cp .env.example .env

In .env, set CPK_INTELLIGENCE_API_KEY to the API key of your CopilotKit Intelligence project. The deploy script stops if this key is not set. It stores the key in AWS Secrets Manager.

Deploy

One command deploys the CDK infrastructure, AgentCore Runtime, and the frontend:

./deploy-langgraph.sh

🎉 Open your app

The deploy script prints an Amplify URL when it finishes. Open it and sign in with your admin_user_email.

Run locally

After you deploy, you can run the agent, the CopilotKit runtime, and the frontend locally. The local stack still uses the Cognito user pool and the AgentCore memory of the deployed stack:

cd docker
cp .env.example .env
# Fill in AWS credentials and STACK_NAME
./up.sh --build
ServicePortDescription
agent8080Your agent, hot-reloads on .py changes
runtime3001CopilotKit Runtime
frontend3000Vite dev server

Tear down

When done, delete all AWS resources to stop charges:

cd infra-cdk && npx cdk destroy --all

Troubleshooting

HTTP 401: Missing Authentication Token

Agent execution failed: Error: HTTP 401:
{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing Authentication Token"},"id":"null"}

Missing Authentication Token is AWS's own error, not a CopilotKit or agent error. AWS returns it when a request reaches an AgentCore or API Gateway endpoint with no credentials, or when the request path matches no deployed route. Check the following, in order:

  • The runtime is actually sending a token. Set AGENTCORE_ACCESS_TOKEN in the environment of the CopilotKit Runtime server, not the frontend. If the variable is unset, the Authorization header interpolates to Bearer undefined, which AWS rejects exactly like a missing header.
  • The token has not expired. Cognito access tokens are short-lived. Mint a fresh one and retry before you debug anything else.
  • AGENTCORE_ENDPOINT_URL is the full invocation URL, ending in /invocations, with the agent ARN URL-encoded: https://bedrock-agentcore.{region}.amazonaws.com/runtimes/{encoded-arn}/invocations. A URL that stops short of /invocations matches no route, and AWS reports that as Missing Authentication Token rather than as a 404.
  • The browser is not calling AgentCore directly. AgentCore requires SigV4 or OAuth2 signing, which a browser cannot perform. Point the frontend at your CopilotKit Runtime endpoint and let the runtime make the AgentCore call server-side.

This error does not apply to the local quickstart

The framework quickstarts run the agent locally on http://localhost:8000, and a local agent server never returns Missing Authentication Token. If you see this error, the runtime is pointed at a deployed AWS endpoint.

How is this guide?