Skip to main content

Reliability primitives for LangGraph — certified stagnation and integrity gates, backed by the Operon categorical framework.

Project description

operon-langgraph-gates

Reliability primitives for LangGraph — drop-in, cert-emitting.

LangGraph issue #6731"agent infinite-loops until recursion limit, burns tokens invisibly" — was closed as NOT_PLANNED. LangChain's answer: "use tool-call limits in middleware."

This package ships that missing native gate, plus a second one for checkpointer-write integrity. Two primitives. No framework adoption. ~10-line diff on an existing StateGraph.

Install

pip install operon-langgraph-gates

Requires operon-ai>=0.34.4 and langgraph>=1.0.

Quickstart

Break infinite loops (StagnationGate)

from langgraph.graph import StateGraph
from operon_langgraph_gates import StagnationGate

graph = StateGraph(State)
graph.add_node("think", StagnationGate.wrap(think_fn, threshold=0.1, history=10))

# Or attach to a conditional edge (route loop-detected runs elsewhere)
graph.add_conditional_edges(
    "think",
    StagnationGate.edge(forward="answer", break_to="escalate", threshold=0.1),
)

# Certificates collected from the run
certs = StagnationGate.collect(graph)

Backed by Paper 4 §4.3: convergence/false-stagnation accuracy 0.960 with real sentence embeddings (all-MiniLM-L6-v2, N = 300 trials). See docs/paper-citations.md for the full citation record, including the loop-detection caveat and a pointer to the archived benchmark data.

Catch checkpointer drift (IntegrityGate)

from langgraph.checkpoint.postgres import PostgresSaver
from operon_langgraph_gates import IntegrityGate

checkpointer = IntegrityGate.wrap(
    PostgresSaver.from_conn_string("..."),
    invariants=[MyState.__annotations__, my_schema_check],
)
graph = workflow.compile(checkpointer=checkpointer)

Backed by Paper 4 §4, Table 3: in the paper's setup, the FULL variant (with DNARepair) achieves 100% detection and 100% repair of injected state corruption, vs 0%/0% for RAW and GUARDED. This package is detection-and-certification only — it does not repair state. It reformulates the idea as a LangGraph-native invariant gate. Paper 5 §3 establishes the preservation-under-compilation framework that the gate's certificate follows. See docs/paper-citations.md for verbatim quotes and the honest caveat.

Try it — HuggingFace Space

Operon StagnationGate Demo — interactive page: pick a preset (identical, diverse, noisy, slow drift), tune the gate parameters, watch is_stagnant flip and the certificate appear. Deterministic text trajectories — no LLM calls.

Examples

Status

Alpha. API may change before 0.1.0 stable. Feedback welcome via Issues.

License

MIT — see LICENSE.

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

operon_langgraph_gates-0.1.0a1.tar.gz (38.8 kB view details)

Uploaded Source

Built Distribution

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

operon_langgraph_gates-0.1.0a1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file operon_langgraph_gates-0.1.0a1.tar.gz.

File metadata

  • Download URL: operon_langgraph_gates-0.1.0a1.tar.gz
  • Upload date:
  • Size: 38.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for operon_langgraph_gates-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 0e7e92f43e92c4e19e11059fa2db44a94d3012f60cdb3fc21a31f63929f7896d
MD5 debb4d3d9eb650507dd8a3e4c7a603ed
BLAKE2b-256 650b98b26bba4a10a8ee4fdbb443d21e1d0ae6bec90a219e63805edfd835085a

See more details on using hashes here.

Provenance

The following attestation bundles were made for operon_langgraph_gates-0.1.0a1.tar.gz:

Publisher: publish.yml on coredipper/operon-langgraph-gates

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

File details

Details for the file operon_langgraph_gates-0.1.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for operon_langgraph_gates-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 a593c74a7eb8919aa8483f0b681047e2930121f4a2de6d724218b81f53a3e077
MD5 387e0dd97c8c7ab55def6bfa826d0145
BLAKE2b-256 a70d827f0fd9f6978ac413373ba45795ab19cf825855311d5f7df65429ba3795

See more details on using hashes here.

Provenance

The following attestation bundles were made for operon_langgraph_gates-0.1.0a1-py3-none-any.whl:

Publisher: publish.yml on coredipper/operon-langgraph-gates

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