Expand description
HTTP server for hosting an agent on AgentCore Runtime.
BedrockAgentCoreApp serves the two routes of the
Runtime HTTP contract:
POST /invocationsparses the JSON body and calls the invocation handler.GET /pingreports health:Healthy, orHealthyBusywhile background work is tracked. Seecrate::tasksandBuilder::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.
- Read the body. A body over the limit gets
413. AContent-Encodingother thanidentitygets415. TheContent-Typeheader is not checked. - Parse the body as JSON. A failure gets
400 {"error": "Invalid JSON", "details": ..}. - Find the session ID in the
X-Amzn-Bedrock-AgentCore-Runtime-Session-Idheader, then in a top-levelsessionIdstring of the body. Empty values do not count. A request without one gets400. - Decode the body into the handler’s request type. A failure gets
400 {"error": "Invalid request body format", "details": ..}. - Call the handler. An
Errgets500 {"error": <Display text of the error>}and a panic gets500 {"error": "Internal error"}. - Encode the handler’s value by the
Acceptheader, or send its stream as Server-Sent Events. SeeResponse.
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§
- Bedrock
Agent Core App - An HTTP server that implements the AgentCore Runtime contract.
- Builder
- Configures a
BedrockAgentCoreApp. Create one withBedrockAgentCoreApp::builder. - Response
- The reply of an invocation handler.
- Warmup
Hook - 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§
- Ping
Status - The health that
GET /pingreports to AgentCore Runtime.
Traits§
- Into
Invocation Response - Conversion of a handler’s return value into a
Response. - Invocation
Handler - An async function that handles
POST /invocations.