APort Agent Guardrail for LangChain
APort Agent Guardrail for LangChain/LangGraph — pre-action authorization for AI agents: an AsyncCallbackHandler that verifies every tool call against your passport and policies before execution. On deny, raises GuardrailViolation.
Install
pip install aport-agent-guardrails-langchain
Requires aport-agent-guardrails (core); installs automatically.
Setup
aport-langchain setup
- Writes config to
~/.aport/langchain/config.yaml. - Run the passport wizard with:
npx @aporthq/aport-agent-guardrails --framework=langchain.
Usage
from aport_guardrails_langchain import APortCallback, GuardrailViolation
from langchain.agents import create_agent
# Add callback to your agent
agent = create_agent(model=model, tools=tools)
try:
result = await agent.ainvoke(
{"messages": [{"role": "user", "content": "run the task"}]},
config={"callbacks": [APortCallback()]},
)
except GuardrailViolation as e:
print(f"Blocked: {e.code} - {e}")
print("Reasons:", e.reasons)
Config is auto-loaded from .aport/config.yaml or ~/.aport/langchain/config.yaml. Override with APortCallback(config_path="/path/to/config.yaml").
Config
- mode:
local|api - passport_path: path to passport JSON (local mode)
- agent_id:
ap_xxx(API mode, hosted passport) - api_url: optional; default
https://api.aport.io
Tests
cd python/langchain_adapter
pip install -e ".[dev]"
pip install -e ../aport_guardrails
pytest tests/ -v
Links
Metadata
Release files for aport-agent-guardrails-langchain 1.0.36
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aport_agent_guardrails_langchain-1.0.36.tar.gz | 6.4 kB | Without provenance | Details for aport_agent_guardrails_langchain-1.0.36.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aport_agent_guardrails_langchain-1.0.36-py3-none-any.whl | Python 3 | none | any | Details for aport_agent_guardrails_langchain-1.0.36-py3-none-any.whl |
Total release size: 11.8 kB
Release files / aport_agent_guardrails_langchain-1.0.36.tar.gz
| Download URL | aport_agent_guardrails_langchain-1.0.36.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70b7346a101ac692a52719eb205c13b840ad88452396778d5e072a63b20e501c
|
|
BLAKE2b-256 checksum How to use checksums |
1de650c905097877f4ce640094d7a6a98c537a32dd40cba3ca8155ee245045eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / aport_agent_guardrails_langchain-1.0.36-py3-none-any.whl
| Download URL | aport_agent_guardrails_langchain-1.0.36-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f258b9e1846073b54cb42566650dc1e4becf5a4c29a88ff97934b229e2ac6216
|
|
BLAKE2b-256 checksum How to use checksums |
26ede44d0f8d6afdd335a3374fc78eb81c87748e0b29be621839950632eb192b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Security for aport-agent-guardrails-langchain 1.0.36
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.