Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

tenbri-langgraph

Tenbri for LangGraph and LangChain: every tool call your agent makes is a signed, chained decision.

pip install --pre tenbri-langgraph
import tenbri

tenbri.init()  # TENBRI_STREAM=./audit/support TENBRI_APPROVER=person:alice
tenbri.instrument_langchain()

From then on every tool call of every LangChain agent and LangGraph graph in the process is recorded, in every thread, with no callbacks to pass. The principal is the agent's name (create_agent(name=...)), else TENBRI_AGENT. tenbri.init() creates the stream and its keys on first use and flushes at exit; see the tenbri package for its settings and @tenbri.decision for your own functions.

Which action, which target, which policy

A tool call is the action of the tool's name. Declare the action in tenbri.toml (the action schemas tenbrid and tenbri schema check validate against) and the record takes its target and rule from there, filled from the tool's arguments:

[actions.issue_refund]
target = "stripe:{charge}"      # each {argument} is filled from the call; validated as *
policy = "policy:refund@14"     # the rule that allowed it: ref@version

init() reads ./tenbri.toml (or TENBRI_SCHEMA). A tool matches an action by its name or its last __ part, so the MCP tool mcp__billing__issue_refund is issue_refund. A plain dict in code says the same, and wins:

tenbri.instrument_langchain(
    actions={"issue_refund": {"target": "stripe:{charge}", "policy": "policy:refund@14"}}
)

Human in the loop

With HumanInTheLoopMiddleware (and a checkpointer), resume the graph the LangGraph way; the answers in the Command are recorded as it starts:

config = {"configurable": {"thread_id": "t1"}}
agent.invoke({"messages": [("user", "refund ch_123")]}, config)  # paused for review
agent.invoke(Command(resume={"decisions": [{"type": "approve"}]}), config)

approve and edit write an approval entry by TENBRI_APPROVER (or init(approver=...), or instrument_langchain(approver=...): a principal, or a function of the tool and its arguments), and the tool's intent names it. reject writes the call's intent and a refused outcome.

Advanced: TenbriCallbackHandler

The one-liner is built on TenbriCallbackHandler, a handler on a stream you opened, passed in callbacks, with resume() recording the answers for a person you name. What it records, below, is what the one-liner records.

from langchain.agents import create_agent
from tenbri import Tenbri
from tenbri_langgraph import TenbriCallbackHandler

log = Tenbri.open("./audit/support", create=True)
tenbri = TenbriCallbackHandler(log, target=lambda tool, args: args.get("charge"))

agent = create_agent(model, tools=[issue_refund], name="support")
agent.invoke({"messages": [("user", "refund ch_123")]}, {"callbacks": [tenbri]})
print(log.verify(log.fingerprint).ok)
  • Before each tool call its intent is durable in the stream, or the tool does not run (the handler has raise_error=True). After it comes the outcome: ok, error, or refused when the tool raises tenbri.Refused. LangGraph's ToolNode re-raises a tool's exception unless handle_tool_errors is set, so a refusal, or an intent that could not be written, ends the run with that exception. A process that dies mid-call leaves the intent open, and the stream's next writer reconciles it as unknown.
  • Who and what: principal is the agent (create_agent(name=...), or principal=), action is the tool, target is what target(tool, args) returns.
  • Inputs: the call's arguments are pinned as a keyed digest (langchain:tool_call/<id>@args); inputs(tool, args) pins more, such as a policy version. Arguments and results are never stored.
  • Selection: tools=["issue_refund"] or a predicate records only those tools.
  • Traces: the active OpenTelemetry span goes into trace (install tenbri-langgraph[otel]); the LangChain run id, the tool call id and the LangGraph thread id go into ext.langchain, so a LangSmith run and a decision find each other.
  • Fail closed by default: when the stream can't be written, the tool call fails. fail_open=True runs the tool anyway and logs a warning.

Human in the loop

With LangChain's HumanInTheLoopMiddleware (and a checkpointer), record the person's answer as you resume the graph:

config = {"callbacks": [tenbri], "configurable": {"thread_id": "t1"}}
agent.invoke({"messages": [("user", "refund ch_123")]}, config)  # paused for review
agent.invoke(tenbri.resume(agent, config, {"decisions": [{"type": "approve"}]}, by="person:alice"), config)

approve and edit write an approval entry, and the tool's intent names it (approval: {by, entry}), so the stream answers "who approved this, and on what basis". reject writes the call's intent and a refused outcome. For an interrupt() of your own, call tenbri.approve(tool, args, by=..., tool_call_id=...) once the person has answered.

A runnable example is in examples/refund_agent.py.

Metadata

Release files for tenbri-langgraph 0.1.0b4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tenbri-langgraph 0.1.0b4
File Size Uploaded Provenance
tenbri_langgraph-0.1.0b4.tar.gz 13.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tenbri-langgraph 0.1.0b4
File Interpreter ABI Platform
tenbri_langgraph-0.1.0b4-py3-none-any.whl Python 3 none any Details

Total release size: 22.8 kB

Release files / tenbri_langgraph-0.1.0b4.tar.gz

Download URL tenbri_langgraph-0.1.0b4.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
336829106e457087a6d630bc12b72a5a2d38fc533285b9e5849fd61c99285a15
BLAKE2b-256 checksum
How to use checksums
3c198e59b404129ce7acc4f2015fd0f0bfbc4f105d35f97ad9b56170fac0043b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / tenbri_langgraph-0.1.0b4-py3-none-any.whl

Download URL tenbri_langgraph-0.1.0b4-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cad792a480eef99a1d417e7d4d8869aee49eed24ee0f8ed67f1bee6265b787ee
BLAKE2b-256 checksum
How to use checksums
70277196a9f4f754397202cec5d90b59064ed19378bbcc753f5974c7e17dd1a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Security for tenbri-langgraph 0.1.0b4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tenbri_langgraph-0.1.0b4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page