Skip to main content

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

Metadata

Release files for aport-agent-guardrails-langchain 1.0.35

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

Source distribution (sdist)

Source distribution for aport-agent-guardrails-langchain 1.0.35
File Size Uploaded
aport_agent_guardrails_langchain-1.0.35.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aport-agent-guardrails-langchain 1.0.35
File Interpreter ABI Platform
aport_agent_guardrails_langchain-1.0.35-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / aport_agent_guardrails_langchain-1.0.35.tar.gz

Download URL aport_agent_guardrails_langchain-1.0.35.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
87d5e75c6c8053a9c2fe03278a507ba6250c5351a0bd84c52f40920346b3c96a
BLAKE2b-256 checksum
How to use checksums
931bc72c3394dd7a02f369332d43a60812d8f8e440daae2b2289d24f920b0a67
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.35-py3-none-any.whl

Download URL aport_agent_guardrails_langchain-1.0.35-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1297e11b08afbf36f839a7dbb0b9f88647c1e31c8b1357ca4f2fc5e404ce2a63
BLAKE2b-256 checksum
How to use checksums
cba968e10229a7e5d7b56bd89e29993cb3048112b6ded3174a12a71c5b14d924
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release history Release notifications | RSS feed

This release

1.0.35 This release

2 release files

1.0.34

2 release files

1.0.33

2 release files

1.0.30

2 release files

1.0.29

2 release files

1.0.28

2 release files

1.0.27

2 release files

1.0.24

2 release files

1.0.23

2 release files

1.0.22

2 release files

1.0.21

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

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