Skip to main content

Earned autonomy for LangGraph — evaluate, interrupt, approve, resume.

Project description

warrantd-langgraph

Splice earned autonomy into LangGraph's interrupt/HITL loop — evaluate, approve, resume.

LangGraph already ships the human-in-the-loop machinery: interrupt() pauses a graph, Command(resume=...) continues it. What it doesn't ship is a policy for when to interrupt — that's usually a hardcoded list of tool names.

This adapter makes it dynamic: earned autonomy from warrantd. A tool starts at MANUAL (every call interrupts for a human), earns SUPERVISED through clean approvals (runs uninterrupted within a value cap), and is bounded by ceilings no metric can move.

pip install warrantd-langgraph

Quickstart

from decimal import Decimal
from langgraph.checkpoint.memory import MemorySaver
from langgraph.prebuilt import create_react_agent
from langgraph.types import Command
from warrantd import (
    ActionClass, ApprovalHistorySignal, AutonomyState, GraduationThresholds,
    InMemoryApprovalHistory, RiskTier, TrustLayer, TrustPolicy,
)
from warrantd_langgraph import ToolBinding, guard_tools

policy = TrustPolicy(
    actions={"issue_refund": ActionClass(
        name="issue_refund", risk=RiskTier.REVERSIBLE_WRITE,
        auto_cap=Decimal("100"), hard_cap=Decimal("1000"),
        max_state=AutonomyState.SUPERVISED,
    )},
    thresholds=GraduationThresholds(
        pass_rate={AutonomyState.SUPERVISED: 1.0, AutonomyState.AUTONOMOUS: 1.0},
        adversarial_pass_rate={AutonomyState.SUPERVISED: 0.0, AutonomyState.AUTONOMOUS: 0.9},
        min_samples={AutonomyState.SUPERVISED: 5, AutonomyState.AUTONOMOUS: 1000},
    ),
)
evidence = InMemoryApprovalHistory()
trust = TrustLayer(policy, audit=my_audit_sink,
                   signals=[ApprovalHistorySignal(evidence, window=10)])

agent = create_react_agent(
    model,
    guard_tools([issue_refund], trust=trust, policy=policy, evidence=evidence,
                bindings={"issue_refund": ToolBinding(value_param="amount")}),
    checkpointer=MemorySaver(),   # interrupts need a checkpointer
)

config = {"configurable": {"thread_id": "t1"}}
result = agent.invoke({"messages": [("user", "refund INV-1 by $50")]}, config)

for intr in result.get("__interrupt__", []):       # REQUIRE_APPROVAL: paused
    print(intr.value["graduation"]["sentence"])
    # -> "this class is 4/10 approvals from SUPERVISED — your decision
    #     feeds its trust record"
    result = agent.invoke(
        Command(resume={intr.id: {"approved": True, "approver": "alice"}}),
        config,
    )

The resume payload is the evidence hook: approved and approver are recorded into the class's trust record before the tool runs (or is declined — a human "no" counts too, and the optional comment is surfaced to the model).

After enough clean approvals the same call stops interrupting. A call above hard_cap never interrupts either: it is blocked outright, with the reason returned as the tool result so the model can adapt. Ceilings never move.

What this adapter does NOT do

  • No decision logic. Every verdict comes from warrantd-core's TrustLayer; this package only translates framework events. (Verify it: GraduationEngine appears only in the display-only progress helper, and no Decision/Verdict is ever constructed here.)
  • No approval UI. Your interrupt handler is the UI; the interrupt payload carries everything to render (args preview, value, reason, the graduation sentence).
  • No MCP gating. For gating MCP servers with zero agent changes, use warrantd-gateway.
  • No persistence by default. InMemoryApprovalHistory resets on restart. For hash-chained, restart-proof evidence:
pip install "warrantd-langgraph[gateway]"
from warrantd_langgraph.stores import sqlite_store
evidence = sqlite_store(".warrantd/evidence.db")   # also usable as audit=

Learn more

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

warrantd_langgraph-0.1.0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

warrantd_langgraph-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file warrantd_langgraph-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for warrantd_langgraph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d196391f3a2689561ff8eca1645fdc3d27d4fc202709ce0a69f95de4a0d42fab
MD5 fb2f25d7be9f25a0cd419a6ae2175fe4
BLAKE2b-256 2f317747b0835cfa4ef01cfa0a23a06d81ae83c862631f823504a0a736560582

See more details on using hashes here.

Provenance

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

Publisher: release.yml on moritzkazooba-wq/warrantd

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

File details

Details for the file warrantd_langgraph-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for warrantd_langgraph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6eeb79e95c41e2914023d423764221eda2c00ea8f42a224a97ff097a637e1f7d
MD5 c7e5e33fe52685ae2f7066e4e67b4dc3
BLAKE2b-256 17add1a90b13185389ccaaf69b2cf948f5c05cb8de3f90d7556bd05360c829c6

See more details on using hashes here.

Provenance

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

Publisher: release.yml on moritzkazooba-wq/warrantd

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