Skip to main content

Crate rig_agentcore

Crate rig_agentcore 

Source
Expand description

Run a Rig agent on AWS Bedrock AgentCore Runtime.

AgentCore runs an agent as an ARM64 container that serves its HTTP protocol contract on port 8080: POST /invocations with a JSON body, answered with JSON or server-sent events, and GET /ping. Each runtime session (the X-Amzn-Bedrock-AgentCore-Runtime-Session-Id header) is one conversation. AgentCoreApp serves that contract for a Rig agent:

  • the session’s conversation is kept between invocations, in memory or in any rig_memory store (see AgentCoreApp::history_store);

  • the reply streams as server-sent events when the caller asks for text/event-stream, and is one JSON object otherwise;

  • each invocation runs in a span that continues the caller’s trace and carries the session as session.id (through rig_otel), which is what AgentCore Observability and Evaluations group a session’s traces by;

  • /ping answers HealthyBusy while an invocation or background work from AgentCoreApp::spawn_task is open, so AgentCore Runtime keeps the session running until that work ends.

  • prompts and replies go on the spans only with AgentCoreApp::record_content (off by default, as in Rig). AgentCore Evaluations needs them to judge a session.

async fn run(agent: rig_agent::Agent) -> Result<(), rig_agentcore::ServeError> {
    rig_agentcore::AgentCoreApp::new(agent)
        .record_content(true)
        .serve()
        .await
}

Re-exports§

pub use rig_memory;

Structs§

AgentCoreApp
A Rig agent served on AgentCore Runtime’s HTTP protocol contract.
BusyGuard
Keeps the app’s /ping at HealthyBusy while it is alive. Get one from AgentCoreApp::track_task. The work is released when the guard drops, which also happens when a task holding it is aborted or panics.

Enums§

ServeError
Why the app stopped serving.

Constants§

DEFAULT_HISTORY_TOKENS
How many tokens of history a session keeps by default.
DEFAULT_MAX_REQUEST_BYTES
The largest /invocations body by default, in bytes: the limit Axum’s JSON extractor already applied. A larger body gets 413.
DEFAULT_MAX_SESSIONS
How many sessions an app keeps by default. AgentCore gives each session its own microVM, so one process usually sees one; this bounds the memory when the app runs elsewhere.
DEFAULT_PORT
The port AgentCore Runtime sends the HTTP protocol to.
SESSION_HEADER
The header AgentCore Runtime names the session with.