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
examples/01_stagnation_breaks_loop.ipynb— reproduces issue #6731 pathology, then fixes it with a ten-line diff.examples/02_integrity_catches_drift.ipynb— a three-node graph silently corrupts state;IntegrityGatecatches it with replayable evidence.
Status
Alpha. API may change before 0.1.0 stable. Feedback welcome via Issues.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e7e92f43e92c4e19e11059fa2db44a94d3012f60cdb3fc21a31f63929f7896d
|
|
| MD5 |
debb4d3d9eb650507dd8a3e4c7a603ed
|
|
| BLAKE2b-256 |
650b98b26bba4a10a8ee4fdbb443d21e1d0ae6bec90a219e63805edfd835085a
|
Provenance
The following attestation bundles were made for operon_langgraph_gates-0.1.0a1.tar.gz:
Publisher:
publish.yml on coredipper/operon-langgraph-gates
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
operon_langgraph_gates-0.1.0a1.tar.gz -
Subject digest:
0e7e92f43e92c4e19e11059fa2db44a94d3012f60cdb3fc21a31f63929f7896d - Sigstore transparency entry: 1328156473
- Sigstore integration time:
-
Permalink:
coredipper/operon-langgraph-gates@7d3133a8227c695c3c01501576dd49b9c57b7d9c -
Branch / Tag:
refs/tags/v0.1.0a1 - Owner: https://github.com/coredipper
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7d3133a8227c695c3c01501576dd49b9c57b7d9c -
Trigger Event:
release
-
Statement type:
File details
Details for the file operon_langgraph_gates-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: operon_langgraph_gates-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a593c74a7eb8919aa8483f0b681047e2930121f4a2de6d724218b81f53a3e077
|
|
| MD5 |
387e0dd97c8c7ab55def6bfa826d0145
|
|
| BLAKE2b-256 |
a70d827f0fd9f6978ac413373ba45795ab19cf825855311d5f7df65429ba3795
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
operon_langgraph_gates-0.1.0a1-py3-none-any.whl -
Subject digest:
a593c74a7eb8919aa8483f0b681047e2930121f4a2de6d724218b81f53a3e077 - Sigstore transparency entry: 1328156482
- Sigstore integration time:
-
Permalink:
coredipper/operon-langgraph-gates@7d3133a8227c695c3c01501576dd49b9c57b7d9c -
Branch / Tag:
refs/tags/v0.1.0a1 - Owner: https://github.com/coredipper
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7d3133a8227c695c3c01501576dd49b9c57b7d9c -
Trigger Event:
release
-
Statement type: