AgentCore Basics
Define and run a minimal agent via the managed harness and SDK/CLI.
Search across all documentation pages
Define and run a minimal agent via the managed harness and SDK/CLI.
This page is the smallest possible round trip through Amazon Bedrock AgentCore: write an entrypoint, deploy it as a runtime, and invoke it. Every other page in this section - Gateway tools, memory, observability - builds on top of this same loop, so it is worth getting comfortable with before adding anything else.
Amazon Bedrock AgentCore is a 2026 preview capability. The class names, decorators, and CLI subcommands below reflect AWS's publicly shown direction at the time of writing, but this is the fastest-moving surface in this whole cookbook - verify each name against current AWS documentation before you build on it.
pip install boto3 bedrock-agentcore (an AWS-published SDK package for wrapping agent entrypoints; verify the current package name). TypeScript: npm install @aws-sdk/client-bedrock-agentcore for the data-plane invoke calls (Node.js 18+).pip install bedrock-agentcore-starter-toolkit or similar) - see the CLI page in this section for what it does. Confirm the current install path before scripting around it.aws configure, environment variables, or a role) with permission to create and invoke AgentCore runtimes - the exact IAM actions are AgentCore-specific and should be pulled from current AWS documentation rather than assumed.Wrap a plain function as the thing AgentCore Runtime will invoke.
# --- Python (illustrative - verify class/decorator names against current AWS docs) ---
from bedrock_agentcore.runtime import BedrockAgentCoreApp
import boto3
app = BedrockAgentCoreApp()
brt = boto3.client("bedrock-runtime", region_name="us-east-1")
@app.entrypoint
def invoke(payload):
prompt = payload.get("prompt", "Say hello.")
resp = brt.converse(
modelId="amazon.nova-lite-v1:0",
messages=[{"role": "user", "content": [{"text": prompt}]}],
)
return {"reply": resp["output"]["message"]["content"][0]["text"]}
if __name__ == "__main__":
app.run() # starts a local server for testing before you deployConverse API, but it could run any framework's agent loop instead.app.run() is described as starting a local dev server so you can exercise the entrypoint before deploying anything.Related: The AgentCore Managed Harness: Model + Prompt + Tools - what belongs inside this entrypoint.
Package and register your entrypoint as a runtime AWS can invoke.
# --- AgentCore CLI (illustrative subcommands - verify against current AWS docs) ---
agentcore configure --entrypoint my_agent.py
agentcore launchCall your hosted agent the same way you would call any AWS data-plane operation.
# --- Python (boto3) --- verify exact operation/param names at build time
import boto3, json
client = boto3.client("bedrock-agentcore", region_name="us-east-1")
resp = client.invoke_agent_runtime(
agentRuntimeArn="arn:aws:bedrock-agentcore:us-east-1:111122223333:runtime/my-agent",
payload=json.dumps({"prompt": "Give me a fun fact."}).encode(),
)
print(json.loads(resp["response"].read()))// --- TypeScript (AWS SDK v3) --- verify exact operation/param names at build time
import { BedrockAgentCoreClient, InvokeAgentRuntimeCommand } from "@aws-sdk/client-bedrock-agentcore";
const client = new BedrockAgentCoreClient({ region: "us-east-1" });
const resp = await client.send(new InvokeAgentRuntimeCommand({
agentRuntimeArn: "arn:aws:bedrock-agentcore:us-east-1:111122223333:runtime/my-agent",
payload: new TextEncoder().encode(JSON.stringify({ prompt: "Give me a fun fact." })),
}));
console.log(new TextDecoder().decode(resp.response as Uint8Array));payload is opaque bytes as far as the runtime API is concerned; your entrypoint decides what shape of JSON it expects.configure/launch step above - creating a runtime and invoking it are separate operations, as with Lambda's create-function vs invoke.Send a richer payload and check for a failed invocation.
# --- Python (boto3) --- verify exact exception types at build time
import boto3, json
from botocore.exceptions import ClientError
client = boto3.client("bedrock-agentcore", region_name="us-east-1")
try:
resp = client.invoke_agent_runtime(
agentRuntimeArn="arn:aws:bedrock-agentcore:us-east-1:111122223333:runtime/my-agent",
payload=json.dumps({"prompt": "List two AWS regions.", "userId": "u-42"}).encode(),
)
print(json.loads(resp["response"].read()))
except ClientError as e:
print("Invocation failed:", e.response["Error"]["Code"])// --- TypeScript (AWS SDK v3) --- verify exact exception types at build time
import { BedrockAgentCoreClient, InvokeAgentRuntimeCommand } from "@aws-sdk/client-bedrock-agentcore";
const client = new BedrockAgentCoreClient({ region: "us-east-1" });
try {
const resp = await client.send(new InvokeAgentRuntimeCommand({
agentRuntimeArn: "arn:aws:bedrock-agentcore:us-east-1:111122223333:runtime/my-agent",
payload: new TextEncoder().encode(JSON.stringify({ prompt: "List two AWS regions.", userId: "u-42" })),
}));
console.log(new TextDecoder().decode(resp.response as Uint8Array));
} catch (err) {
console.error("Invocation failed:", err);
}userId here) is just part of your own payload contract, not an AgentCore-defined field.Exercise your code without touching AWS at all.
# --- Local dev loop (illustrative - verify current tooling) ---
python my_agent.py
# in another terminal:
curl -X POST http://localhost:8080/invocations \
-H "Content-Type: application/json" \
-d '{"prompt": "Say hello."}'Use the control-plane client to see what is registered.
# --- Python (boto3) --- control-plane client name/operation illustrative, verify at build time
import boto3
control = boto3.client("bedrock-agentcore-control", region_name="us-east-1")
for r in control.list_agent_runtimes().get("agentRuntimes", []):
print(r.get("agentRuntimeArn"), "-", r.get("status"))// --- TypeScript (AWS SDK v3) --- control-plane client name/operation illustrative, verify at build time
import { BedrockAgentCoreControlClient, ListAgentRuntimesCommand } from "@aws-sdk/client-bedrock-agentcore-control";
const control = new BedrockAgentCoreControlClient({ region: "us-east-1" });
const out = await control.send(new ListAgentRuntimesCommand({}));
for (const r of out.agentRuntimes ?? []) console.log(r.agentRuntimeArn, "-", r.status);Stack versions: This page was written for boto3 1.43.x (Python 3.10+) and the AWS SDK for JavaScript v3 (Node.js 18+). Amazon Bedrock AgentCore is a fast-moving 2026 preview capability - verify exact API/CLI surface against current AWS docs before relying on specific method names.
Reviewed by Chris St. John·Last updated Jul 24, 2026