Expand description
§serve-agentcore (experimental)
Run a serve app on Amazon Bedrock AgentCore Runtime, part of the Everruns ecosystem.
Experimental. Like serve, this is a proof of concept with no compatibility promise.
AgentCore Runtime runs one container per session in its own microVM and talks to it over HTTP on port 8080. This crate serves that contract on top of serve’s host:
GET /ping:{"status":"Healthy"}, orHealthyBusywhile a turn runs, so AgentCore keeps the session alive for background work.POST /invocations: an AG-UI 1.0 run of the app’s agent, streamed as server-sent events. The body is AG-UIRunAgentInput(what the AgentCore AG-UI protocol forwards), or{"prompt": "..."}(whatInvokeAgentRuntimecallers usually send). The AG-UI thread defaults to the AgentCore session id fromX-Amzn-Bedrock-AgentCore-Runtime-Session-Id.GET /ws: the same runs over AgentCore’s WebSocket transport. Each text message is one invocation body; the run’s AG-UI events come back as one text message each, so a connection can carry several runs in turn.- serve’s own
/v1wire API and/health, unchanged, for local use andeval --against.
Everything else is serve’s: the app, its agents and tools, approvals,
ask_user, and the durable SQLite session log, kept on AgentCore session
storage (/mnt/workspace) when the runtime mounts it, so sessions survive
the microVM stopping.
use serve::prelude::*;
#[agent]
fn assistant() -> Agent {
Agent::builder()
.model("anthropic/claude-sonnet-5")
.instructions("Be brief.")
.build()
}
#[tokio::main]
async fn main() -> serve::Result {
// No command (what AgentCore runs) or `agentcore`: the AgentCore
// contract on :8080. `dev`, `start`, `eval`, `manifest`, `deploy`:
// serve's own commands.
serve_agentcore::start(App::builder().discover().build()).await
}Structs§
Constants§
- PORT
- The port the AgentCore HTTP and AG-UI protocol contracts require.
- SESSION_
HEADER - The header AgentCore Runtime sets on every request, naming the session (and so the microVM) it routed to.
- SESSION_
STORAGE - Where serve-agentcore looks for AgentCore session storage when
SERVE_DATA_DIRis not set: the mount path the AgentCore docs use.
Functions§
- router
- The AgentCore contract around
app:/ping,/invocations, and serve’s/v1wire API. Returns the router and the agent/invocationsruns. - start
- Run the app: with no command, or with
agentcore, serve the AgentCore Runtime contract; any other command is serve’s (seeserve::start).