Skip to main content

Module runtime

Module runtime 

Source
Expand description

HTTP server for hosting an agent on AgentCore Runtime.

BedrockAgentCoreApp serves the two routes of the Runtime HTTP contract:

  • POST /invocations parses the JSON body and calls the invocation handler.
  • GET /ping reports health: Healthy, or HealthyBusy while background work is tracked. See crate::tasks and Builder::ping.

With Builder::warmup_hook it also serves the build warmup hook, as POST on the path that you choose. See WarmupHook for its requests and replies.

§Invocation requests

The server takes these steps in order. The first failure decides the reply.

  1. Read the body. A body over the limit gets 413. A Content-Encoding other than identity gets 415. The Content-Type header is not checked.
  2. Parse the body as JSON. A failure gets 400 {"error": "Invalid JSON", "details": ..}.
  3. Find the session ID in the X-Amzn-Bedrock-AgentCore-Runtime-Session-Id header, then in a top-level sessionId string of the body. Empty values do not count. A request without one gets 400.
  4. Decode the body into the handler’s request type. A failure gets 400 {"error": "Invalid request body format", "details": ..}.
  5. Call the handler. An Err gets 500 {"error": <Display text of the error>} and a panic gets 500 {"error": "Internal error"}.
  6. Encode the handler’s value by the Accept header, or send its stream as Server-Sent Events. See Response.

Every error reply of the steps above is a JSON object with an error string, and so is the 404 for an unknown path. A known path with another method gets 405 with an Allow header and an empty body.

Structs§

BedrockAgentCoreApp
An HTTP server that implements the AgentCore Runtime contract.
Builder
Configures a BedrockAgentCoreApp. Create one with BedrockAgentCoreApp::builder.
Response
The reply of an invocation handler.
WarmupHook
The build warmup hook of AgentCore Runtime: the path that serves it and a handler for each of its two calls. Give it to Builder::warmup_hook.

Enums§

PingStatus
The health that GET /ping reports to AgentCore Runtime.

Traits§

IntoInvocationResponse
Conversion of a handler’s return value into a Response.
InvocationHandler
An async function that handles POST /invocations.