Skip to main content

Crate bedrock_agentcore

Crate bedrock_agentcore 

Source
Expand description

Amazon Bedrock AgentCore SDK for Rust.

The runtime module hosts an agent on AgentCore Runtime. It serves POST /invocations and GET /ping as the Runtime HTTP contract requires.

use bedrock_agentcore::{RequestContext, runtime::BedrockAgentCoreApp};
use serde_json::{Value, json};

async fn handle(payload: Value, ctx: RequestContext) -> Result<Value, std::convert::Infallible> {
    Ok(json!({ "echo": payload, "session_id": ctx.session_id() }))
}

#[tokio::main]
async fn main() -> Result<(), bedrock_agentcore::Error> {
    BedrockAgentCoreApp::builder().invocation(handle).build()?.run().await
}

The identity module gets the credentials that the agent needs for the services it calls, such as API keys, from AgentCore Identity.

§Features

  • runtime (default): the HTTP server in the runtime module.
  • identity (default): the client of AgentCore Identity in the identity module. It depends on the AWS SDK for Rust.

With neither feature the crate has no networking dependencies. The context and tasks modules are always available.

Re-exports§

pub use context::RequestContext;
pub use http;

Modules§

context
Per-invocation request context.
identity
Credentials from AgentCore Identity for the services an agent calls.
runtime
HTTP server for hosting an agent on AgentCore Runtime.
tasks
Tracking of background work for health reporting.

Structs§

Error
Error returned by this crate.

Enums§

ErrorKind
The reason an SDK operation failed. Read it with Error::kind.