Bedrock AgentCore
Bedrock AgentCore is a local emulation of the AgentCore control plane and runtime data plane. It lets an application create and inspect agent resources, store memory events, configure gateway and tool metadata, and exercise runtime-shaped requests without running a real agent, model, tool, or external credential flow.
Service boundary
AgentCore presents two related AWS services through the local endpoint. The control plane keeps resource state. The data plane accepts runtime and harness requests so clients can test request and response handling.
| Plane | Main purpose | Emulated result |
|---|---|---|
bedrock-agentcore-control | Manage runtimes, endpoints, gateways, memories, identities, credentials, tools, rules, policies, and tags | Stateful resource records with AWS-shaped responses |
bedrock-agentcore | Invoke a runtime or harness | A fixed JSON response or an AWS event stream |
The service uses REST-JSON request shapes. Some operations use standard resource paths, while others use operation names in the path or action suffixes. See Request routing and AWS protocols for the broader request dispatch model, and Bedrock Runtime for the separate model-invocation service.
Runtime lifecycle
Runtime registry
The runtime registry gives each agent runtime a stable identity, a current version, and a history of immutable versions. A new runtime is ready at once and receives a default endpoint plus a workload identity, so a client can create a runtime and then resolve its basic serving metadata without waiting for a real deployment.
An update changes the current runtime configuration and appends a new version. Existing versions remain readable. Runtime endpoints point at a published version and expose the distinction between the requested target version and the version currently serving.
References: src/…/BedrockAgentCoreControlService.java• L29-34 src/…/BedrockAgentCoreControlService.java• L74-135 src/…/BedrockAgentCoreControlService.java• L153-189 src/…/BedrockAgentCoreControlController.java• L59-93
Runtime invocation
InvokeAgentRuntime checks the runtime request boundary but does not execute the runtime. It accepts the request body as opaque bytes, returns the configured JSON body, and copies the runtime session identifier header to the response. Runtime existence checks are optional and are disabled by default, which keeps the data plane useful for clients that only need a protocol stub.
The runtime invocation path follows this high-level flow:
flowchart LR
A[Client request] --> B[Runtime ARN and session header]
B --> C{Optional runtime lookup}
C -->|valid or disabled| D[Configured JSON response]
C -->|unknown ARN| E[Resource not found]
D --> F[Response with session header]
The request may include a qualifier and account identifier for wire compatibility. The emulator logs those values but does not use them to select execution behavior.
References: src/…/BedrockAgentCoreController.java• L21-83 src/…/BedrockAgentCoreService.java• L9-27
Harness invocation
InvokeHarness tests a streaming chat contract rather than an agent. The harness ARN is carried in the query string, the runtime session id is carried in a header, and the message list is carried in the JSON body. The harness request boundary parses the body before it starts the stream, then the harness validates the request and echoes the text from the last user message in the same event-stream order used by Bedrock clients.
The harness stream contains a message start, content block start, text deltas, content block stop, message stop, and metadata. An empty body or a JSON value that is not an object becomes an empty request, while invalid JSON fails before the stream starts. An empty message list or a list without a user turn is valid and returns the configured empty reply. Tools may be present in the request, but the harness does not create tool-use blocks, run skills, call a model, or perform multi-turn iteration.
References: src/…/BedrockAgentCoreHarnessInvokeController.java• L25-86 src/…/BedrockAgentCoreHarnessService.java• L18-28 src/…/BedrockAgentCoreHarnessService.java• L58-99 src/…/BedrockAgentCoreHarnessService.java• L124-152
Gateway resources
Gateway metadata
Gateways model an MCP-facing entry point and its targets. The control plane stores the gateway identity, URL, authorizer and role metadata, protocol type, status, and nested targets. Target configuration is retained as request data so clients can create and inspect a gateway topology.
Gateway operations do not forward a request to an MCP server or invoke a target. Gateway rules also remain control-plane data. They describe static or weighted routing, configuration-bundle overrides, path conditions, and IAM-principal conditions, but the emulator does not apply those rules to a live gateway call.
References: src/…/BedrockAgentCoreGatewayService.java• L22-79 src/…/BedrockAgentCoreGatewayService.java• L158-225 src/…/BedrockAgentCoreGatewayController.java• L51-71 src/…/BedrockAgentCoreGatewayRuleService.java• L38-84
Memory resources
Memory registry
Memory resources provide named, active containers for event history. The control plane stores memory settings such as expiry, description, encryption key, execution role, and tags. Memory record extraction and retrieval are not emulated; the useful data-plane behavior is the direct event store.
Memory creation returns an active resource immediately. Updates change supported settings, while deletion removes the resource and reports a deleting state. Memory identifiers and memory ARNs also connect the control-plane resource to event and tagging requests.
References: src/…/BedrockAgentCoreMemoryService.java• L23-84 src/…/BedrockAgentCoreMemoryService.java• L87-149 src/…/BedrockAgentCoreMemoryController.java• L63-144
Memory event flow
Memory events are stored records grouped by memory, actor, and session. A create request must include an actor, timestamp, and payload member; an empty payload is valid. The service generates a session id when the request omits one and uses the main branch when no branch is supplied.
Reads return the newest events first. A page has a default size of 20 and accepts values from 1 through 100. A continuation token names the last event in the prior page, while includePayloads=false removes payload data from each returned event. Deleting a memory also removes its stored events.
The event flow connects a memory resource to an event session as follows:
flowchart LR
A[Create event] --> B{Memory and request are valid}
B -->|no| C[Validation or not found error]
B -->|yes| D[Assign session and event id]
D --> E[Store event]
E --> F[List newest first]
F --> G[Get or delete one event]
H[Delete memory] --> I[Remove its events]
An unknown actor or session returns an empty list. A malformed memory id is a validation error, while a well-formed id for a missing memory is a not-found error. An omitted payload member is also invalid, even though an empty payload array is accepted.
References: src/…/BedrockAgentCoreEventService.java• L26-35 src/…/BedrockAgentCoreEventService.java• L70-107 src/…/BedrockAgentCoreEventService.java• L116-150 src/…/BedrockAgentCoreEventService.java• L164-199 src/…/BedrockAgentCoreMemoryService.java• L87-149
Identity and credential resources
Workload identities
Workload identities link AgentCore resources to a named identity record. Creating a runtime creates an associated identity and returns its ARN with the runtime metadata. Clients can also manage identities directly and set the allowed OAuth2 return URLs used by identity flows.
The identity API uses operation names in the request path and places its input in the JSON body. Identity records are local metadata; they do not create an IAM principal or enforce access on runtime requests. See IAM and authentication for the emulator-wide identity and authorization model.
References: src/…/BedrockAgentCoreIdentityService.java• L19-24 src/…/BedrockAgentCoreIdentityService.java• L45-99 src/…/BedrockAgentCoreIdentityController.java• L26-131 src/…/BedrockAgentCoreControlService.java• L121-130
Credential providers
Credential providers describe how a gateway or agent could obtain API key or OAuth2 credentials. The control plane supports managed and external secret references, provider-specific OAuth2 configuration, validation, updates, lists, and deletes.
The emulator stores provider metadata and returns synthetic managed secret and OAuth2 discovery references. It does not contact an OAuth provider, resolve an external secret, exchange a token, or use a provider to authorize a gateway call. Provider ARNs use the token-vault style expected by the AgentCore API rather than the normal runtime resource shape.
References: src/…/BedrockAgentCoreCredentialProviderService.java• L20-37 src/…/BedrockAgentCoreCredentialProviderService.java• L39-94 src/…/BedrockAgentCoreCredentialProviderService.java• L161-224 src/…/BedrockAgentCoreIdentityController.java• L133-294
Tool resources
Browser and code interpreter resources
Browser, browser profile, and code interpreter APIs let clients build tool-related resource records. Custom resources become ready immediately, while system browser and code interpreter identifiers are exposed as built-in records that cannot be deleted.
These resources validate names, network settings, tags, and selected resource fields. They do not start a browser, run code, create a session, or execute a tool call. Their role is to make control-plane setup and client compatibility tests behave like AgentCore resource setup.
References: src/…/BedrockAgentCoreToolsService.java• L22-79 src/…/BedrockAgentCoreToolsService.java• L102-197 src/…/BedrockAgentCoreToolsService.java• L218-327 src/…/BedrockAgentCoreToolsController.java• L45-143 src/…/BedrockAgentCoreToolsController.java• L144-291
Policies and tags
Resource policies
Resource policies are per-ARN documents with get, put, and delete operations. The emulator validates the resource ARN and policy size, then stores the policy as text for later reads.
Policy storage does not evaluate statements and does not grant or deny a request. Authorization remains outside this AgentCore policy surface and follows the shared emulator IAM behavior.
References: src/…/BedrockAgentCoreResourcePolicyService.java• L12-54 src/…/BedrockAgentCoreResourcePolicyController.java• L19-72
Resource tags
Tagging uses the shared /tags/{resourceArn} route and dispatches by the resource type in the ARN. Runtimes, gateways, and memories support tag create, removal, and listing. Tags supplied during resource creation remain resource metadata, while later tag calls update the same record.
The tag handler checks that the ARN names the local account and region before changing state. Other AgentCore resource types, such as credential providers or tool resources, are not taggable through this surface.
References: src/…/BedrockAgentCoreTagHandler.java• L12-18 src/…/BedrockAgentCoreTagHandler.java• L37-67 src/…/BedrockAgentCoreTagHandler.java• L69-103
Configuration and scope
Service configuration
The control and data planes can be enabled independently. The data plane also lets a test choose the fixed runtime response, whether runtime ARNs must resolve, and the text used by harness replies.
| Setting | Default | Effect |
|---|---|---|
FLOCI_SERVICES_BEDROCK_AGENT_CORE_CONTROL_ENABLED | true | Enables resource management APIs |
FLOCI_SERVICES_BEDROCK_AGENT_CORE_ENABLED | true | Enables runtime and harness APIs |
FLOCI_SERVICES_BEDROCK_AGENT_CORE_INVOKE_RESPONSE | {"output":"yes"} | Body returned by InvokeAgentRuntime |
FLOCI_SERVICES_BEDROCK_AGENT_CORE_VALIDATE_RUNTIME_EXISTS | false | Makes runtime invocation reject unknown full runtime ARNs |
FLOCI_SERVICES_BEDROCK_AGENT_CORE_HARNESS_ECHO_PREFIX | You said: | Prefix for the last user message |
FLOCI_SERVICES_BEDROCK_AGENT_CORE_HARNESS_EMPTY_REPLY | No user message was supplied. | Reply when no user text is available |
Configuration affects emulation behavior only. It does not turn on model inference, gateway forwarding, tool execution, identity enforcement, or policy evaluation.
References: src/…/EmulatorConfig.java• L2614-2640 src/…/BedrockAgentCoreController.java• L45-83 src/…/BedrockAgentCoreHarnessInvokeController.java• L35-86 src/…/BedrockAgentCoreHarnessService.java• L47-55
Change checklist
When these files or sections are changed, remember to consider these:
- Keep runtime version creation, endpoint target versions, and runtime ARN generation aligned. An endpoint must point to a published version.
- Keep the harness query parameters, session headers, body parsing rules, and event-stream frame order aligned with the SDK wire contract.
- Keep the harness data-plane route separate from the control-plane harness route. The two resources must not claim the same request path.
- Keep memory resource checks, event request validation, pagination rules, and event storage cleanup aligned. A malformed memory id and an unknown valid memory id must remain different error cases.
- Keep the shared tag route aligned with the three supported ARN resource kinds and local account and region checks.
- Keep credential-provider input unions aligned with their vendor name and managed or external secret mode.
- Keep control-plane and data-plane enablement separate when changing service registration or configuration.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Runtime update refers to no published version through an endpoint | Endpoint creation or update fails instead of pointing at a usable runtime version | Validate the target version against the runtime version history |
| Harness ARN or runtime session id is sent in the wrong place or has the wrong shape | Request fails before the event stream starts | Keep ARN in the query string and session id in the required header |
| Harness body is invalid JSON | ValidationException before the event stream starts | Parse and validate the body before committing the streaming response |
Event request omits payload instead of sending an empty list | ValidationException even though an empty payload is valid | Preserve the difference between a missing member and an empty array |
Event request uses a maxResults value below 1 or above 100 | ValidationException and no page is returned | Enforce the page-size bounds before reading events |
| Memory deletion does not remove its stored events | Later event reads can return data for a deleted memory | Delete all event records when the memory deletion event is observed |
| Tag request uses a foreign account or region ARN | ResourceNotFoundException and no local tag change | Check ARN identity before resource lookup or mutation |
| Caller expects a resource policy or gateway rule to enforce access or routing | Stored metadata has no effect on the request | Treat both features as control-plane records only |
| Caller expects tool or credential resources to execute | No browser, code run, token exchange, or tool-use block occurs | Use these resources for setup and protocol tests only |
Key files
| File | Why to read it |
|---|---|
| src/…/BedrockAgentCoreController.java | Data-plane boundary for runtime invocation and optional runtime lookup |
| src/…/BedrockAgentCoreHarnessInvokeController.java | Harness request boundary and event-stream response setup |
| src/…/BedrockAgentCoreHarnessService.java | Harness validation, echo behavior, and event-stream shape |
| src/…/BedrockAgentCoreEventService.java | Memory event validation, persistence, pagination, and cleanup |
| src/…/BedrockAgentCoreControlService.java | Runtime versions, endpoints, and workload identity linkage |
| src/…/BedrockAgentCoreGatewayService.java | Gateway and nested target resource model |
| src/…/BedrockAgentCoreMemoryService.java | Memory resource lifecycle and tag support |
| src/…/BedrockAgentCoreIdentityService.java | Workload identity lifecycle |
| src/…/BedrockAgentCoreCredentialProviderService.java | API key and OAuth2 provider metadata |
| src/…/BedrockAgentCoreToolsService.java | Browser, browser profile, and code interpreter resources |
| src/…/BedrockAgentCoreTagHandler.java | Shared tagging dispatch and ARN scope checks |
| src/…/BedrockAgentCoreResourcePolicyService.java | Resource policy storage boundary |