Skip to main content

DuraGraph Python SDK

CI PyPI version Python versions Downloads License GitHub Stars

Python SDK for DuraGraph — durable, replayable agent workflows.

Define a graph with decorators, register it with the control plane, and get crash-safe execution, event-sourced replay, and live observability for free. Like Temporal for AI agents — in Python.

Installation

The package is published as duragraph on PyPI (renamed from duragraph-python in v0.3.0; the old name is frozen at 0.2.1 and will not receive further releases). We recommend uv for dependency management.

# With uv (recommended)
uv add duragraph
uv add 'duragraph[openai]'
uv add 'duragraph[anthropic]'
uv add 'duragraph[all]'

# With pip
pip install duragraph

Quick Start

from duragraph import Graph, llm_node, entrypoint

@Graph(id="customer_support")
class CustomerSupportAgent:
    """A customer support agent that classifies and responds to queries."""

    @entrypoint
    @llm_node(model="gpt-4o-mini")
    def classify(self, state):
        """Classify the customer intent."""
        return {"intent": "billing"}

    @llm_node(model="gpt-4o-mini")
    def respond(self, state):
        """Generate a response based on intent."""
        return {"response": f"I'll help you with {state['intent']}."}

    # Define flow
    classify >> respond


# Run locally
agent = CustomerSupportAgent()
result = agent.run({"message": "I have a billing question"})
print(result)

# Or deploy to control plane
agent.serve("http://localhost:8081")

Features

Decorator-Based Graph Definition

from duragraph import Graph, llm_node, tool_node, router_node, human_node

@Graph(id="my_agent")
class MyAgent:
    @llm_node(model="gpt-4o-mini", temperature=0.7)
    def process(self, state):
        return state

    @tool_node
    def search(self, state):
        results = my_search_function(state["query"])
        return {"results": results}

    @router_node
    def route(self, state):
        return "path_a" if state["condition"] else "path_b"

    @human_node(prompt="Please review")
    def review(self, state):
        return state

Streaming

async for event in agent.stream({"message": "Hello"}):
    if event.type == "token":
        print(event.data, end="")
    elif event.type == "node_completed":
        print(f"\nNode {event.node_id} completed")

Subgraphs

@Graph(id="research")
class ResearchAgent:
    @llm_node
    def research(self, state):
        return {"findings": "..."}

@Graph(id="main")
class MainAgent:
    research = ResearchAgent.as_subgraph()

    @entrypoint
    def plan(self, state):
        return state

    plan >> research

Requirements

  • Python 3.10+
  • DuraGraph Control Plane (for deployment)

Documentation

Related modules

The Python SDK lives in the duragraph monorepo alongside its siblings:

Path Description
/ Core engine (Go, embeds the React dashboard incl. visual workflow editor)
go-sdk/ Go SDK
examples/ Example projects (multi-language)
docs/ Documentation site source

Contributing

See CONTRIBUTING.md for guidelines.

License

Apache 2.0 - See LICENSE for details.

Metadata

Release files for duragraph 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for duragraph 0.3.3
File Size Uploaded Provenance
duragraph-0.3.3.tar.gz 325.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for duragraph 0.3.3
File Interpreter ABI Platform
duragraph-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 408.1 kB

Release files / duragraph-0.3.3.tar.gz

Download URL duragraph-0.3.3.tar.gz
Size 325.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ad85ac39103767fa9c46dca3873ebb8c61b277a21577d324c30f181c450afef4
BLAKE2b-256 checksum
How to use checksums
5fa10348c94a3423e8f9dfc9c76abf72aafd6324753642daa69915c0042003ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 11, 2026.

Transparency log

Release files / duragraph-0.3.3-py3-none-any.whl

Download URL duragraph-0.3.3-py3-none-any.whl
Size 82.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9bf064667f44ce6ebffc7fbf5ae6b15c5addf9dbc65b2424772fbc88e9ea71c1
BLAKE2b-256 checksum
How to use checksums
2a44edf00185c72c42056738f40a8aed9f0e5e18f9db514bcd1cb927fe54ba0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 11, 2026.

Transparency log

Security for duragraph 0.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for duragraph-0.3.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page