# Amazon Bedrock AgentCore + Diagrid

**Host your agent on Amazon Bedrock AgentCore. Make its execution durable with Diagrid.**

:::info Preview
Amazon Bedrock AgentCore support in Diagrid is in preview. Features and behavior can change before general availability.
:::

[Amazon Bedrock AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agents-tools-runtime.html) runs your agent container in sessions, each in its own microVM, and gives it an endpoint. On AgentCore alone, an agent's progress lives in its session. A session ends when it is idle or reaches its maximum lifetime, and a crash loses the run's progress.

Diagrid gives every agent run [durable execution](https://docs.diagrid.io/concepts/durable-execution): each model call and tool call is recorded as a step of a workflow. When a session ends or the container crashes, the run picks up where it left off, from its last completed step, once a session of the Runtime is running. Its result stays in Diagrid after the request that started it ends.

**Diagram: An AgentCore agent with Diagrid durable execution.** The agent container runs in an AgentCore session, calls its model in Amazon Bedrock itself, and records every step of the run in Diagrid over outbound HTTPS and gRPC.

- **Amazon Bedrock AgentCore**: Agent container (Your agent + Diagrid)
- **Diagrid**: Workflow engine, Execution history, Diagrid CLI and Console
- Your client (invoke), Amazon Bedrock (model)

- Your client (invoke) → Agent container (Your agent + Diagrid)
- Agent container (Your agent + Diagrid) → Workflow engine (every step)
- Agent container (Your agent + Diagrid) → Amazon Bedrock (model)
- Workflow engine → Execution history
- Execution history → Diagrid CLI and Console (async)

## What each platform provides

| | Amazon Bedrock AgentCore | Diagrid |
| --- | --- | --- |
| **Models and tools** | Works with the model provider your agent calls | Works with the models and tools your agent already uses |
| **Agent runtime** | [AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agents-tools-runtime.html): your container in a session microVM, an invocation endpoint and an execution role | Never runs your agent code. Your agent connects to Diagrid over outbound HTTPS and gRPC |
| **Execution** | Starts and ends sessions, and routes each invocation to its session | Runs the agent's control loop as a durable workflow and stores its history. Can start and stop AgentCore sessions to run the agent's workflow worker |
| **Visibility** | CloudWatch logs and metrics of the Runtime | Every run as a workflow: status, steps, inputs, outputs and timing |

## What you can build

Some agents need more than a session can give them: they run longer than a session lives, they act on events when no one is waiting, or they take actions that you must be able to account for. Run them on AgentCore, and make their execution durable with Diagrid:

| Your agent | On AgentCore alone | With Diagrid |
| --- | --- | --- |
| **A research or report agent** that makes dozens of model and tool calls over an hour or more | A crash, or the end of the session at its maximum lifetime of 8 hours, loses the run's progress | The run resumes on a new session from its last completed step |
| **A back-office agent** that triages invoices or tickets as they arrive | You keep a session running, or build what starts one when work arrives | Diagrid starts a worker when work is waiting and stops it when there is none |
| **A support agent** whose conversations span days | The conversation is lost when the session ends, after 15 minutes with no request by default | The conversation is stored in Diagrid, under the session ID |
| **An operations agent** that issues refunds, opens tickets or changes systems | A run that restarts repeats the steps it had already completed, and nothing records what the agent did | Completed steps aren't run again, and every step's input and output can be inspected |

## Three ways to run the agent

- **On your machine, connected to Diagrid.** The [quickstart](https://docs.diagrid.io/integrations/aws-bedrock-agentcore/getting-started) runs the agent locally, with the same HTTP contract AgentCore uses.
- **As an AgentCore hosted agent.** Your clients invoke the AgentCore Runtime, and each session's container runs the agent and executes its runs. See [AgentCore hosted agents](https://docs.diagrid.io/integrations/aws-bedrock-agentcore/hosted-agents).
- **In Diagrid-managed sessions.** Your clients start runs through Diagrid. Diagrid starts an AgentCore session to run the agent when there is work, and stops it when there is none. See [Diagrid-managed sessions](https://docs.diagrid.io/integrations/aws-bedrock-agentcore/diagrid-managed-sessions).

## Hosted agents or Diagrid-managed sessions?

The difference is what your app calls: AWS or Diagrid.

### Hosted agents: your app calls AWS

- Your client invokes the AgentCore Runtime with AWS credentials, as it would any AgentCore agent.
- AgentCore starts a session for each session ID, and the agent runs inside it.
- Diagrid records each step of the run, so the run is durable.
- Your client and AgentCore control the session's lifecycle. A session starts when a client invokes it, and ends after 15 minutes with no request, by default.
- If a session ends during a run, the run's progress is saved in Diagrid. The run resumes when a session of the Runtime is running. To collect its result, your client invokes the session again with `{}`, which also starts a session if none is running.

It works as a request and a response: your client sends a task and waits for the answer, for up to 14 minutes.

### Diagrid-managed sessions: your app calls Diagrid

- Your client starts a run through Diagrid, and doesn't call AWS.
- When the agent has work waiting and no worker is connected, Diagrid starts an AgentCore session in your AWS account. The session's container connects to Diagrid as the agent's worker and executes the run.
- When the agent has no work, Diagrid stops the session.
- If a worker fails, Diagrid starts a new one, and the run continues from its last completed step with no action from your client.

Here AgentCore is compute that Diagrid starts and stops as needed.

### Compare

| | Hosted agents | Diagrid-managed sessions |
| --- | --- | --- |
| **Your app calls** | AWS (the AgentCore Runtime) | Diagrid |
| **What starts a session** | Your client's request | Diagrid, when work is waiting and no worker is connected |
| **Style** | Send a task and wait for the answer, up to 14 minutes | Start a run and collect its result later. No request waits for the run |
| **Recovery** | Progress is saved in Diagrid. Your client invokes the session again to collect the result | Automatic: Diagrid starts a new worker |
| **Sessions** | One per session ID. Each ends after its idle timeout | None while there is no work. Diagrid stops the worker when the agent has no work |
| **AWS setup** | Image, secret, execution role and Runtime | The same, plus a role Diagrid can assume, which `diagrid agent compute setup` generates |
| **Use it when** | Your callers use AWS IAM, you want a standard AgentCore agent, and you want the smallest change | Work is driven by events or schedules, runs are long, and you want recovery and scaling without client action |

Use hosted agents when your app calls the agent through AgentCore and waits for the answer. Use Diagrid-managed sessions when your app starts runs through Diagrid: Diagrid runs AgentCore sessions only while there is work, and recovers a failed run on its own.

## What Diagrid adds to an AgentCore agent

- **Durable execution with automatic failure recovery.** Each model call and tool call runs as a workflow activity. A failed activity is retried, and a run interrupted when AgentCore ends a session resumes from its last completed step on the next worker.
- **Persistent execution history and checkpoints.** Diagrid stores the result of every completed step in the project's workflow state store. A resumed run reads those results from the history and doesn't call the model or the tool again for them. Activities run at least once, so keep tools with side effects idempotent.
- **Runs longer than a request.** A run isn't tied to one session or one request. When an invocation times out, the run keeps going in Diagrid, and its result stays in the run's output.
- **Conversation across invocations.** Invocations with the same AgentCore session ID share one conversation, stored in Diagrid.
- **Workflow-level visibility.** Every agent run is a workflow that you can [inspect](https://docs.diagrid.io/operate/project-operations/workflows) with the Diagrid CLI or in the Diagrid Console, with the input and output of each step.
- **Verifiable execution.** In a project with workflow history signing, Diagrid signs every history event, which gives you a tamper-evident record of what ran, and attests results that cross identities. You turn it on when you create the project. See [Verifiable execution](https://docs.diagrid.io/concepts/verifiable-execution).
- **Sessions only when there is work.** With Diagrid-managed sessions, Diagrid starts an AgentCore session when the agent has pending work and no worker is connected, and stops it when the agent has no work. No AWS credentials are stored in Diagrid.

## Supported frameworks

`AgentcoreRunner` serves the Diagrid runner of each of these frameworks. The guides use Strands. To use another framework, see [Use another framework](https://docs.diagrid.io/integrations/aws-bedrock-agentcore/getting-started#use-another-framework).

| Framework | Diagrid package | Runner |
| --- | --- | --- |
| Strands | `diagrid[awsbedrock,strands]` | `diagrid.agent.strands.DaprWorkflowAgentRunner` |
| LangGraph | `diagrid[awsbedrock,langgraph]` | `diagrid.agent.langgraph.DaprWorkflowGraphRunner` |
| Deep Agents | `diagrid[awsbedrock,deepagents]` | `diagrid.agent.deepagents.DaprWorkflowDeepAgentRunner` |
| LangChain | `diagrid[awsbedrock,langchain]` | `diagrid.agent.langchain.DaprWorkflowAgentRunner` |
| OpenAI Agents | `diagrid[awsbedrock,openai_agents]` | `diagrid.agent.openai_agents.DaprWorkflowAgentRunner` |
| Pydantic AI | `diagrid[awsbedrock,pydantic_ai]` | `diagrid.agent.pydantic_ai.DaprWorkflowAgentRunner` |
| Google ADK | `diagrid[awsbedrock,adk]` | `diagrid.agent.adk.DaprWorkflowAgentRunner` |
| Claude Agent SDK | `diagrid[awsbedrock,claude_agents]` | `diagrid.agent.claude_agents.DaprWorkflowAgentRunner` |
| CrewAI | `diagrid[awsbedrock,crewai]` | `diagrid.agent.crewai.DaprWorkflowAgentRunner` |
| smolagents | `diagrid[awsbedrock,smolagents]` | `diagrid.agent.smolagents.DaprWorkflowAgentRunner` |

HolmesGPT isn't supported. The [reference](https://docs.diagrid.io/integrations/aws-bedrock-agentcore/reference#supported-frameworks) says why, and what each framework needs for conversation history.

The guides' agent calls Amazon Bedrock with the AWS credentials of its container: the execution role on AgentCore, and your AWS CLI login on your machine. No model API key is stored. An agent in another framework can call Amazon Bedrock the same way, through that framework's Bedrock client, or call another model provider with a key stored in the agent's secret.

## Next steps

- [Quickstart](https://docs.diagrid.io/integrations/aws-bedrock-agentcore/getting-started) — Create a durable Strands agent that serves the AgentCore contract, and run it on your machine.
- [AgentCore hosted agents](https://docs.diagrid.io/integrations/aws-bedrock-agentcore/hosted-agents) — Deploy the agent to AgentCore Runtime and invoke it there.
- [Diagrid-managed sessions](https://docs.diagrid.io/integrations/aws-bedrock-agentcore/diagrid-managed-sessions) — Let Diagrid start AgentCore sessions when the agent has work, stop them when it has none, and recover interrupted runs.
- [Reference](https://docs.diagrid.io/integrations/aws-bedrock-agentcore/reference) — Requests, health checks, environment variables, frameworks and conversation history of the AgentCore runner.
- [Agent frameworks](https://docs.diagrid.io/develop/agents) — Tutorials and access policies for each framework Diagrid supports.
