# rig-agentcore
Run a [Rig](https://github.com/0xPlaygrounds/rig) agent on
[AWS Bedrock AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-http-protocol-contract.html).
AgentCore runs an agent as an ARM64 container serving its HTTP protocol contract on port
8080. `AgentCoreApp` serves it for a Rig agent:
| `POST /invocations` | Takes `{"prompt": "..."}`. Answers `{"response": "...", "status": "success"}`, or server-sent events (`{"text"}` as the model writes, then `{"response"}`) when the caller accepts `text/event-stream`. |
| `GET /ping` | `{"status": "Healthy"}`. |
```rust
rig_agentcore::AgentCoreApp::new(agent)
.record_content(true) // prompts and replies on the spans, for AgentCore Evaluations
.serve() // 0.0.0.0:$PORT, default 8080; stops on SIGTERM
.await?;
```
- **Sessions:** the `X-Amzn-Bedrock-AgentCore-Runtime-Session-Id` header names the
conversation; each session's messages are kept and sent with its next invocation.
- **Traces:** each invocation runs in an `agentcore.invocation` span that continues the
caller's trace (`traceparent`) and gives every span under it `session.id`, through
[`rig-otel`](https://crates.io/crates/rig-otel). With rig-otel's `aws` feature exporting to CloudWatch, that
is what AgentCore Observability and AgentCore Evaluations read.
- **Content:** `record_content(true)` records prompts and replies on the GenAI spans.
AgentCore Evaluations needs them to judge a session; they are off by default, as in
Rig.
## Verified on AWS
On 2026-11-26, rig-lab (a Rig agent with a calculator tool, Claude Haiku 4.5 on
Bedrock) ran on AgentCore Runtime in us-east-1 with `record_content(true)` and
rig-otel's `aws` export, deployed as AWS documents it (ECR image, execution role,
Transaction Search). A two-turn session (3×47−29, then ÷4) kept its conversation, its
spans reached CloudWatch (`aws/spans`) under the session id, and AgentCore Evaluations'
built-in evaluators judged it from those spans: GoalSuccessRate 1.0, Helpfulness 0.83
and Correctness 1.0 per turn. The scripts are in rig-lab's `deploy/agentcore`.
What made the spans evaluable: the scope `opentelemetry.instrumentation.rig`,
`session.id` on every span, an `invoke_agent` span with `gen_ai.task.input` and
`gen_ai.task.output`, and Rig's `chat` and `execute_tool` spans with content recorded.
## Testing
`cargo test` serves the contract over real HTTP for agents on scripted models: ping, a
session keeping its conversation, sessions kept apart, streamed replies, a bad body, and
an invocation continuing the caller's trace with the session on every span.