Skip to main content

chap-langgraph

Bridge between LangGraph and the CHAP Coordinator. Wraps the human-in-the-loop interrupt boundary so every review decision becomes a hash-linked, replayable audit entry, without changing the inside of your existing graph nodes.

LangGraph event              CHAP envelope
-----------------            -------------------------
interrupt() called           task.complete + review.request
Command(resume=...) sent     decide.approve | decide.reject | decide.override

The bridge adds three lines to your existing LangGraph node. The override path also turns reviewer edits into JSON Patches automatically, so the audit chain captures what changed and why, not just approved/ rejected.

Install

pip install chap-langgraph

Depends on chap-coordinator>=0.2.9. LangGraph itself is optional: the bridge accepts any dict-shaped state and any opaque decision payload, so it works in environments without LangGraph and is trivial to unit-test.

Quick start

from chap_coordinator import Coordinator
from chap_langgraph import ChapBridge, hil_review

coord = Coordinator(default_profiles=["core/1.0", "review/1.0"])
bridge = ChapBridge(
    coord,
    workspace="wsp_drafter",
    agent="agent:drafter#v1",
    reviewer="human:alice@example.org",
)

# Inside your existing LangGraph node:
def drafter_node(state):
    draft = produce_draft(state)
    chap_state = hil_review(bridge, draft, kind="draft_response")
    return chap_state            # spread into LangGraph state, then interrupt()

# After the interrupt resumes with Command(resume=decision):
def resolve_review(state, decision):
    applied = bridge.apply_decision(state["chap_task_id"], decision)
    return {"draft": applied or state["chap_artefact"], **state}

The decision payload mirrors what a reviewer typically returns:

"approve"                                           # decide.approve
"reject"                                            # decide.reject
{"action": "reject", "rationale": "..."}            # decide.reject (rich)
{"diff": [...], "rationale": "...", "tags": [...]}  # decide.override

What you get in the audit chain

After one hil_review + apply_decision cycle, calling bridge.audit() returns the full chain:

seq=0  workspace.create
seq=1  participant.join     agent:drafter#v1
seq=2  participant.join     human:alice@example.org
seq=3  task.create          kind=draft_response
seq=4  task.complete        agent:drafter#v1
seq=5  review.request       to=human:alice@example.org
seq=6  decide.override      diff=[...] rationale="..." tags=[...]

Every entry carries prev_hash, so you can verify the chain externally or anchor it to a SCITT transparency service with the audit-scitt/1.0 profile.

Examples

See examples/ for runnable end-to-end demos:

  • examples/01-basic-review.py: single drafter node, one human approval.
  • examples/02-override-cycle.py: agent draft, human edits, audit chain.

Compatibility

Tested against:

  • chap-coordinator 0.2.9
  • langgraph 0.2.x (optional)
  • Python 3.10, 3.11, 3.12, 3.13

License

Apache 2.0. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chap_langgraph-0.2.9.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

chap_langgraph-0.2.9-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file chap_langgraph-0.2.9.tar.gz.

File metadata

  • Download URL: chap_langgraph-0.2.9.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for chap_langgraph-0.2.9.tar.gz
Algorithm Hash digest
SHA256 26356aad375e3ea16e02b6d332cf07f63e651f71cbf8d11bf3541bd3509935f5
MD5 8d8064949f294f09503b0bd528efa244
BLAKE2b-256 d20bc3e7c1a722cf2076d6bbbea3a8f0e6dc2be04e94c91bcea9747ebe3da65d

See more details on using hashes here.

File details

Details for the file chap_langgraph-0.2.9-py3-none-any.whl.

File metadata

  • Download URL: chap_langgraph-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for chap_langgraph-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ab551670698411ab69bbf0727615888732dad5d1aec1aa90d79b84579e745219
MD5 3bdecb2b32df1433f58b456d893296f0
BLAKE2b-256 e0660a542a5ac8f51b7e3ad3bc0d0572a8ed967cf84973214a87a347a2628834

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page