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

# Add callback to your agent
agent = initialize_agent(
    tools=tools,
    llm=llm,
    callbacks=[APortCallback()]
)

# On deny, the callback raises GuardrailViolation
try:
    result = await agent.ainvoke(...)
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

Download files

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

Source Distribution

aport_agent_guardrails_langchain-1.0.30.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file aport_agent_guardrails_langchain-1.0.30.tar.gz.

File metadata

File hashes

Hashes for aport_agent_guardrails_langchain-1.0.30.tar.gz
Algorithm Hash digest
SHA256 d8694ccbeb8ddcbc343b176936dd09cb0311986752ab557b6a6345bafd6b1877
MD5 f4fed80cb57b0bfa5b10cdd892d7e118
BLAKE2b-256 26779f2aa51322d3ae5fae03ea82672060aee8a8bf86b7cdad1fefa078da428a

See more details on using hashes here.

File details

Details for the file aport_agent_guardrails_langchain-1.0.30-py3-none-any.whl.

File metadata

File hashes

Hashes for aport_agent_guardrails_langchain-1.0.30-py3-none-any.whl
Algorithm Hash digest
SHA256 6bf79a2511d0769246130f8bcf2809b35d395c47249e4e473e3553a78bed9bc0
MD5 205d3a6f2c284ded4dea8ab3d3141f29
BLAKE2b-256 0aa7af21b01c79c6b4eecbf145da8661b957effdafbd12c8d77c2e254db90f1b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.30 This release

2 files

1.0.29

2 files

1.0.28

2 files

1.0.27

2 files

1.0.26

2 files

1.0.25

2 files

1.0.24

2 files

1.0.23

2 files

1.0.22

2 files

1.0.21

2 files

1.0.20

2 files

1.0.19

2 files

1.0.18

2 files

1.0.17

2 files

1.0.16

2 files

1.0.15

2 files

1.0.14

2 files

1.0.13

2 files

1.0.12

2 files

1.0.11

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

Supported by

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