Metadata-Version: 2.4
Name: pydantic-ai-absurd
Version: 0.1.0
Summary: Durable execution of Pydantic AI agents on Postgres via Absurd.
Author-email: Marcelo Trylesinski <marcelotryle@gmail.com>
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: absurd-sdk>=0.4.0
Requires-Dist: pydantic-ai>=2.0.0b1
Requires-Dist: typing-extensions>=4.10.0
Description-Content-Type: text/markdown

# Pydantic AI Absurd

<p align="center"><em>Durable execution for Pydantic AI agents, on Postgres alone.</em></p>

---

Agents run for a while - a model call, a tool call, another model call. When the worker dies in the middle of that, the run is usually lost: you restart from zero and pay for every token again.

**Pydantic AI Absurd** fixes that. Call `agent.run()` inside a durable task and every model and MCP call is checkpointed into Postgres. If the worker crashes, a new one resumes from the last completed step - no restart, no re-spent tokens. Same idea as Pydantic AI's Temporal integration, but with no Temporal, no Redis, no broker: just the Postgres you already have.

## Installation

```bash
pip install pydantic-ai-absurd
```

## Example

```python
from absurd_sdk import AsyncAbsurd
from pydantic_ai import Agent
from pydantic_ai_absurd import AbsurdAgent

absurd = AsyncAbsurd("postgresql://localhost/absurd", queue_name="agents")
agent = AbsurdAgent(Agent("openai:gpt-5.2", name="analyst"), absurd)

@absurd.register_task(name="analyse")
async def analyse(params, ctx):
    result = await agent.run(params["prompt"])
    return {"output": result.output}

await absurd.spawn("analyse", {"prompt": "Analyse Q3 revenue"})
await absurd.work_batch(batch_size=1)
```

You author a task, call the agent inside it, and run it durably. That's the whole idea.

## Documentation

Read the docs at **[kludex.github.io/pydantic-ai-absurd](https://kludex.github.io/pydantic-ai-absurd/)** - a step-by-step tutorial, how durability actually works, tools and MCP servers, and a production guide.
