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 agentWhat 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-strandsThe CLI downloads the full AgentCore template and sets up config.yaml for you.
Configure
Open config.yaml and set your details:
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 sentThen create the .env file in the project root:
cp .env.example .envIn .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-strands.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| Service | Port | Description |
|---|---|---|
agent | 8080 | Your agent, hot-reloads on .py changes |
runtime | 3001 | CopilotKit Runtime |
frontend | 3000 | Vite dev server |
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_TOKENin the environment of the CopilotKit Runtime server, not the frontend. If the variable is unset, theAuthorizationheader interpolates toBearer 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_URLis 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/invocationsmatches no route, and AWS reports that asMissing Authentication Tokenrather 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?