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.3.tar.gz (5.0 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.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: antarraksha_langchain-0.1.3.tar.gz
  • Upload date:
  • Size: 5.0 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.3.tar.gz
Algorithm Hash digest
SHA256 9da4fa921f213c95e10e173798cb2a457f362cde0ac561d3e7a6e19dcbfe8651
MD5 b33e68bedc06d66ef1b7f714a6472c60
BLAKE2b-256 47d093e9e249960875f17fc620c9dbf161546499dd09f76e82e0311eba4f0687

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for antarraksha_langchain-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e046992aaca82d6a077ca20f6d2f52182f12e2e0322f4aa6a16dcb427fedf508
MD5 48092cc71f50ecdca6d39858d137434b
BLAKE2b-256 2527bb2d16b8bfa7b2d36cbf7f488603b3551d3b6452db04aa7f1deeea3d5e37

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