> For the complete documentation index, see [llms.txt](/llms.txt).
> A full single-fetch corpus is available at [llms-full.txt](/llms-full.txt).
---
title: Run any AI agent framework on a durable workflow runtime
description: Wrap LangGraph, OpenAI Agents SDK, Vercel AI SDK, or plain Python in durable AGNT5 steps.
tags: ["Frameworks", "Agents", "Durability"]
date: 2026-05-13
last_verified: 2026-05-13
audience: both
---

AGNT5 does not require you to throw away an existing agent framework. This
cookbook shows how to keep LangGraph, OpenAI Agents SDK, Vercel AI SDK, or a
plain Python tool loop while adding durable execution, replay, and traces
underneath.

## Scenario

Your team already has an agent that calls tools and returns a structured result.
It works locally, but production failures are hard to recover from. You want the
agent call to run inside a durable workflow without rewriting the agent.

## What you build

- A wrapper function around existing agent logic.
- A workflow that checkpoints the framework result.
- Trace metadata for model calls, tool calls, and outputs.
- A recovery path after worker or API failures.
- A migration path that keeps framework choice flexible.

## Wrap the existing agent

Treat the existing agent as a step implementation.

```python
@function
async def run_existing_agent(request: AgentRequest) -> AgentResult:
    result = await existing_agent.invoke(
        input=request.prompt,
        metadata={"customer_id": request.customer_id},
    )
    return AgentResult.model_validate(result)
```

Then orchestrate it with AGNT5.

```python
@workflow
async def durable_agent_run(ctx: WorkflowContext, request: AgentRequest) -> AgentResult:
    prepared = await ctx.step(prepare_request, request)
    result = await ctx.step(run_existing_agent, prepared)
    return await ctx.step(record_agent_result_once, request.request_id, result)
```

The agent framework remains inside `run_existing_agent`. AGNT5 owns the durable
step boundary around it.

## Trace integration

At minimum, include:

- framework name and version,
- model name,
- tool names,
- final structured output,
- external side-effect receipts.

If the framework exposes callback hooks, map those events into AGNT5 trace
metadata. If it does not, record the final input and output at the step
boundary.

## Recovery model

On replay, AGNT5 returns the journaled `AgentResult` instead of calling the
framework again. On retry after a failed attempt, the wrapper runs again with the
same input. Any side effects inside the framework still need idempotency keys.

## Production checks

- The framework call only runs inside a step.
- The step result is structured and serializable.
- Tool side effects use stable idempotency keys.
- The trace links framework events back to the AGNT5 run ID.
- Replay does not call the model again for completed steps.

## Next steps

- [Retry AI workflow steps without duplicate side effects](/cookbooks/retry-without-duplicate-side-effects.md)
- [Build a deep research agent](/cookbooks/deep-research-agent.md)
- [Debug AI workflows with traces, not scattered logs](/cookbooks/workflow-native-observability.md)
