Skip to main content

Temporal integration for LangGraph - durable execution for stateful AI agents.

Project description

Langgraph Temporal

Logo

Temporal integration for LangGraph — durable execution for stateful AI agents.

Run your existing LangGraph StateGraph as a Temporal Workflow with automatic recovery from failures, distributed node execution, and zero-resource human-in-the-loop.

This project is experimental, use at your own risk

Installation

pip install langgraph-temporal

Requirements: Python >= 3.10, langgraph >= 1.0.0, temporalio >= 1.7.0

Quick start

1. Run a local Temporal server

A docker-compose.yml is provided to run Temporal locally with PostgreSQL and Elasticsearch.

cp .env.ci .env
make start_temporal

2. Create langgraph workflow

Take any compiled LangGraph graph, wrap it in TemporalGraph, start a Worker, and invoke:

import asyncio
from typing import TypedDict

from langgraph.graph import END, START, StateGraph
from temporalio.client import Client as TemporalClient
from temporalio.worker import UnsandboxedWorkflowRunner

from langgraph.temporal import TemporalGraph


class State(TypedDict):
    message: str


def greet(state: State) -> dict:
    from time import sleep
    sleep(10) # simulate work
    return {"message": f"Hello, {state['message']}!"}


async def main():
    # 1. Build a normal LangGraph
    builder = StateGraph(State)
    builder.add_node("greet", greet)
    builder.add_edge(START, "greet")
    builder.add_edge("greet", END)
    graph = builder.compile()

    # 2. Connect to Temporal and wrap the graph
    client = await TemporalClient.connect("localhost:7233")
    tg = TemporalGraph(graph, client, task_queue="my-queue")

    # 3. Start a Worker (runs Activities that execute your nodes)
    worker = tg.create_worker(workflow_runner=UnsandboxedWorkflowRunner())

    async with worker:
        result = await tg.ainvoke(
            {"message": "world"},
            config={"configurable": {"thread_id": "greeting-1"}},
        )

    print(result)  # {"message": "Hello, world!"}


asyncio.run(main())

Note: LangGraph imports modules restricted by Temporal's sandbox, so UnsandboxedWorkflowRunner() is required when creating the Worker.

3. Open Temporal UI

The Temporal Web UI is available at http://localhost:8233

Demo

License

MIT

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

langgraph_temporal-0.2.0.tar.gz (31.0 MB view details)

Uploaded Source

Built Distribution

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

langgraph_temporal-0.2.0-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langgraph_temporal-0.2.0.tar.gz
  • Upload date:
  • Size: 31.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langgraph_temporal-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dcb64dfbde0b8a0676bf93c16eb7d5794d6f5e3b435458f02dda6a7a4fa1e46a
MD5 cc85577868752071d157b41b8784e847
BLAKE2b-256 a90d3695806bbf0de8e48a6f6b8f20ebe1500fb5124318de8d3e76c195dc6685

See more details on using hashes here.

Provenance

The following attestation bundles were made for langgraph_temporal-0.2.0.tar.gz:

Publisher: release.yml on pradithya/langgraph-temporal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for langgraph_temporal-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e357ab4c5d5cf8de17ec73722879f82215cc12347f51b0f237160a9b99651e55
MD5 b82a9d308684749f94d2a9ff7ef2bc05
BLAKE2b-256 1ab899d4c99f79ca964fd154d466bc91ec7e2f552cf22ef1a19736c633ca5425

See more details on using hashes here.

Provenance

The following attestation bundles were made for langgraph_temporal-0.2.0-py3-none-any.whl:

Publisher: release.yml on pradithya/langgraph-temporal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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