langgraph-phm-guard
Deterministic physics/bounds tool-call guard for LangGraph ToolNode — a wrap_tool_call interceptor that denies physically impossible tool arguments before the tool executes.
Where content-safety guardrails check what the model says, this checks whether what the agent is about to do is physically possible: faster-than-light speeds, negative masses, NaN leaking into measurements, impossible depths — short-circuited with an evidence-bearing ToolMessage (PHM_VETO | speed=400000000.0 exceeds hard limit 299792458.0).
Features
- Deterministic: fixed rule table, no LLM in the judging path, no network; every verdict is recomputable
- Three-state exits: clean calls run (
Proceed), fixable violations guide the model (PHM_GUIDE), impossible calls hard-veto (PHM_VETO) - Operator-declared bounds: extend/override the default hard limits per deployment via
hard_limits=... - Real-dispatch tested: tests drive langgraph's actual
ToolNodeexecution machinery (_arun_one→wrap_tool_call), not mocked wrappers
Install
pip install langgraph-phm-guard
Usage
from langgraph.prebuilt import ToolNode
from langgraph_phm_guard import phm_tool_guard
node = ToolNode(
[launch_probe, read_sensor],
wrap_tool_call=phm_tool_guard(mode="deny"), # or mode="guide"
)
Custom bounds (operator-declared caps override the default table):
node = ToolNode(
tools,
wrap_tool_call=phm_tool_guard(hard_limits={"speed": 300.0}), # 300 m/s fleet cap
)
Default rule table:
| Quantity | Hard limit |
|---|---|
| speed / velocity | 299,792,458 m/s |
| rpm | 500,000 |
| force_n | 10,000,000 N |
| power_w | 1,000,000,000 W |
| altitude_m | 40,000,000 m |
| depth_m | 12,000 m |
Negative values are forbidden for mass-like quantities; all numeric values must be finite (NaN/inf denied).
Origin
Proposed in langgraph#9428; maintainer guidance was that a validator belongs at the existing wrap_tool_call hook — this package is that validator. The physical-checking core ships in phm-lite-check (PyPI) and the same rule table is merged into microsoft/PyRIT as PhysicsConsistencyScorer.
License
MIT
Metadata
Release files for langgraph-phm-guard 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langgraph_phm_guard-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for langgraph_phm_guard-0.1.0-py3-none-any.whl |
Release files / langgraph_phm_guard-0.1.0-py3-none-any.whl
| Download URL | langgraph_phm_guard-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
336748a08fdbaa20740168719638593bb9cccae8c7fbbb2dca43e4f73d309509
|
|
BLAKE2b-256 checksum How to use checksums |
67732f00f2d1a587a547707fb5b9cad8e55692c280e472b5401017d775e85540
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Security for langgraph-phm-guard 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.