AgentCore separates hosting, tool access, identity, memory, and observability. A small local runtime example makes the invocation contract visible before adding cloud deployment and service-specific configuration.

Service boundaries

Capability Contract to establish
Runtime Invocation schema, response behavior, session lifecycle
Gateway Exposed tools, schemas, target authentication
Identity Inbound caller identity and outbound credentials
Memory Actor/session ownership, retention, retrieval
Observability Trace correlation, useful signals, redaction

A pinned runtime starter without model calls

Use Python 3.12 and bedrock-agentcore==1.0.0, the SDK release from October 15, 2025. Save this as runtime_example.py. It intentionally validates an invocation without calling a paid model or creating cloud resources.

from bedrock_agentcore.runtime import BedrockAgentCoreApp

app = BedrockAgentCoreApp()

@app.entrypoint
def handle(payload):
    prompt = payload.get("prompt")
    if not isinstance(prompt, str) or not prompt.strip():
        return {"error": "prompt must be a nonempty string"}
    return {"message": "Received a valid prompt", "characters": len(prompt)}

if __name__ == "__main__":
    app.run()

Run python runtime_example.py on an available local port supported by this SDK. The runtime exposes its invocation/health interface. A local invocation check is:

curl --fail http://localhost:8080/invocations   -H 'Content-Type: application/json'   -d '{"prompt":"hello"}'

Expect a message and a character count of five. This checks the runtime contract, not model quality or AWS authentication. Deployment additionally requires a compatible image/package, region, execution role, and service configuration; use the matching SDK and samples as a unit.

Agent application service boundaries

Conceptual illustration; labels describe responsibilities, not a deployment specification.

Credentials should never become output

Do not print an API key when it is retrieved or add it to a trace. Record a non-sensitive provider identifier or success/failure state instead. Avoid a process-global credential or conversational agent when it can mix different users’ identity or state.

Inbound authentication establishes who may invoke a runtime. Outbound credentials establish which external service a tool may call. They are different trust boundaries. Tool descriptions and model-generated arguments do not override either policy.

Streaming needs framing

An SSE transport contains event boundaries and possibly multiple data: lines. Removing quote characters corrupts JSON and text. Use a supported SSE client, collect a complete event’s data, and then decode the payload according to its contract. A partial network chunk is not necessarily one application message.

Memory has an owner

Keep actor identity and session identity explicit. Scope long-term retrieval to the authorized actor/namespace, distinguish conversation-event expiry from derived-memory retention, and verify deletion behavior. Test that one user’s session cannot retrieve another’s facts.

Observe and clean up

Trace invocations and tool attempts with non-sensitive identifiers. Check initialization, timeout, retry, and cancellation separately. A cloud example should inventory runtime deployments, images, roles, gateway targets, memory resources, and log retention; remove only exercise-owned resources when finished.

References