Skip to main content

Durable execution of Pydantic AI agents on Postgres via Absurd.

Project description

Pydantic AI Absurd

Durable execution for Pydantic AI agents, on Postgres alone.


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

pip install pydantic-ai-absurd

Example

import asyncio

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}


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


if __name__ == "__main__":
    asyncio.run(main())

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, a step-by-step tutorial, how durability actually works, tools and MCP servers, and a production guide.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_ai_absurd-0.2.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_ai_absurd-0.2.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_ai_absurd-0.2.0.tar.gz.

File metadata

  • Download URL: pydantic_ai_absurd-0.2.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pydantic_ai_absurd-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1a649d99517941004324e65936196dd76c77be1978ae8166754b89c0a436edb8
MD5 3926bc757d61035fd20de10e160bf9f6
BLAKE2b-256 5bb204a6f06277f14d8e003ca4b5945a0f197a1ea88a709bad335df7b9a4eef0

See more details on using hashes here.

File details

Details for the file pydantic_ai_absurd-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pydantic_ai_absurd-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pydantic_ai_absurd-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dad29ec0ec2ea6f3e1285800968252ec13aefa8686d156f7ac86eab51acbbdf8
MD5 1bf4950e7c4f4315ca4a9364aded5114
BLAKE2b-256 7c04ce77b4faa4399713f3b9399e39b2f5910679288c67ab4cc66475a9b8b5d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page