Skip to main content

durable.wrapper

Wrap PydanticAI agents with DBOS durable execution.

The wrap_agent_durable function takes a plain pydantic_ai.Agent and returns a DBOSAgent that persists every model interaction as a DBOS workflow step, enabling automatic recovery on pod restart.

wrap_agent_durable

def wrap_agent_durable(agent: Any, *, agent_id: str | None = None) -> Any

Wrap a PydanticAI Agent with DBOS durable execution.

Parameters

agent : pydantic_ai.Agent The plain PydanticAI Agent instance to wrap. agent_id : str | None Optional agent identifier (used in log messages).

Returns

DBOSAgent The agent wrapped with durable execution capabilities.

Raises

ImportError If DBOS dependencies are not installed. RuntimeError If wrapping fails for any reason.