Skip to main content

Antarraksha AI Agent Enforcement SDK for LangChain

Project description

antarraksha-langchain

Antarraksha AI Agent Enforcement SDK for LangChain.

Installation

pip install antarraksha-langchain

Quick Start

Attach Antarraksha as a callback handler on your LLM. Registration happens automatically on first use — no login, no API key, no signup required.

from antarraksha_langchain import AntarrakshaCallbackHandler
from langchain_anthropic import ChatAnthropic

handler = AntarrakshaCallbackHandler(agent_id="my-langchain-agent")

llm = ChatAnthropic(model="claude-sonnet-4-5", callbacks=[handler])
print(llm.invoke("Hello").content)

Run your agent normally — every LLM call, tool call, and chain call is now enforced against Antarraksha policy.

Tool Wrapping (optional)

Wrap individual LangChain tools for inline enforcement:

from langchain_community.tools import ShellTool
from antarraksha_langchain import AntarrakshaSafeTool, AntarrakshaClient

client = AntarrakshaClient(agent_id="my-langchain-agent")
client.register()

safe_shell = AntarrakshaSafeTool(wrapped_tool=ShellTool(), antarraksha_client=client)
safe_shell.run("ls")

Parameters

Parameter Default Description
agent_id None Unique identifier for your agent. Triggers auto-registration on first use.
base_url "https://antarraksha.ai" Antarraksha endpoint. Override for self-hosted / dev.
passport_id None Optional pre-issued passport ID (e.g. ANTK-PASS-xxx).
sdk_key None Optional pre-issued SDK key. If omitted and agent_id is set, the SDK auto-registers and obtains one.
fail_closed True If True, deny on enforcement-server unreachable. Set False for fail-open during early integration.
block_on_deny True If True, raise PermissionError when Antarraksha returns DENY.

Enforcement Behavior

  • on_llm_start fires before every LLM call. DENY raises PermissionError.
  • on_tool_start fires before every tool invocation. DENY raises PermissionError.
  • on_chain_start fires for every chain run (informational; no enforcement halt).
  • Every call is logged and visible at https://antarraksha.ai/registry.

Corporate Network Note

If you're behind a corporate TLS-inspection proxy and see SSLCertVerificationError, install:

pip install pip-system-certs

This makes Python trust your Windows / macOS system certificate store.

Project details


Download files

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

Source Distribution

antarraksha_langchain-0.1.4.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

antarraksha_langchain-0.1.4-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file antarraksha_langchain-0.1.4.tar.gz.

File metadata

  • Download URL: antarraksha_langchain-0.1.4.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for antarraksha_langchain-0.1.4.tar.gz
Algorithm Hash digest
SHA256 66a27894bd078bf71d79f34c35c5cc09f50ee3d04a2b87f813a579425856f565
MD5 365709e7cfc07678fd3599219b658d7e
BLAKE2b-256 cebfaf8169a980ba80bcaf69cff5d3f9e1b711f5b7e4c5413bc2657b1b17f6b6

See more details on using hashes here.

File details

Details for the file antarraksha_langchain-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for antarraksha_langchain-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a96058fb8f54ee2ef9fb57ffbc00ff4510f4e01188e25e2b6f632c4e8affcdc5
MD5 c04201582a36b6a33c164f84d3e3f454
BLAKE2b-256 6c53ed9ee41e0c730b4b89405dc8454fabcfaf40fc123b2be0240491c22d17bd

See more details on using hashes here.

Supported by

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