xshieldai-langchain
🔍 Verification status (2026-05-17 IST)
- Tests: ⚠️ no pytest suite yet — planned in v1.1.0. See PROOF-STACK.md.
- Examples: ✅ 1 runnable example: examples/governed_agent.py. Run against a local AEGIS instance (
bun /root/aegis/src/dashboard/server.tson port 4850).- Live demo: ⚠️ planned (Tier 3)
- Phase-1 limits: Callback fails open if AEGIS is unreachable (
KavachGateErroronly raised on definitive DAN-3/4 block). If you require fail-closed, wrap with your own pre-flightclient.state()check.Behaviour is end-to-end testable today: start AEGIS, run the example, fire a destructive prompt, watch the gate intercept. Automated pytest fixtures land in v1.1.0.
KavachOS DAN gate callback for LangChain agents.
Intercepts every tool call through the AEGIS KAVACH gate before execution. Zero agent code changes — add the callback and every tool invocation is governed.
Install
pip install xshieldai-langchain
Quick start
from xshieldai_langchain import KavachGateCallback
callback = KavachGateCallback(
base_url="http://localhost:4850", # AEGIS server
on_block="raise", # raise KavachGateError on DAN-3/4
dry_run=False,
)
# LangChain agent — pass callback in config
result = agent.invoke(
{"input": "summarise the quarterly report"},
config={"callbacks": [callback]},
)
# Or attach to a single tool:
result = my_tool.invoke("drop table users", config={"callbacks": [callback]})
KavachGateCallback parameters
| Parameter | Default | Description |
|---|---|---|
base_url |
http://localhost:4850 |
AEGIS server URL |
token |
$AEGIS_TOKEN |
Bearer auth token |
on_block |
"raise" |
"raise" → KavachGateError · "warn" → print + continue |
dry_run |
False |
Classify only — no notification, no human-in-loop polling |
tool_name |
"langchain" |
Label appearing in audit records |
session_id |
auto-generated | Audit grouping key (one per agent session) |
Direct client
from xshieldai_langchain import AegisClient
client = AegisClient(base_url="http://localhost:4850")
# Pre-flight budget check
state = client.state()
if state["budget"]["breached"]:
raise RuntimeError("Daily budget breached — halt")
# Manual gate call
result = client.gate(command="rm -rf /var/postgres", tool_name="my-agent")
print(result) # {"allow": false, "level": 4, "reason": "DAN-4 catastrophic..."}
# Audit query
records = client.audit(session_id="lc-abc123", status="stop", limit=20)
How it works
KavachGateCallback.on_tool_start() fires before any tool execution.
It POSTs to POST /api/v1/kavach/gate on the AEGIS server.
- DAN-1/2: allowed immediately, logged.
- DAN-3: notify approver via Telegram/WhatsApp, wait for ALLOW/STOP.
- DAN-4: blocked immediately,
KavachGateErrorraised.
All policy is in AEGIS — the callback is a thin HTTP relay.
AEGIS server
Run with: bun /root/aegis/src/dashboard/server.ts
Default port: 4850
Gate endpoint: POST /api/v1/kavach/gate
License
AGPL-3.0 — see LICENSE.
Metadata
Release files for xshieldai-langchain 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| xshieldai_langchain-1.0.1.tar.gz | 5.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xshieldai_langchain-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.3 kB
Release files / xshieldai_langchain-1.0.1.tar.gz
| Download URL | xshieldai_langchain-1.0.1.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
095740735fa0d78a32f96d6ca501f6d116fd8dd503c703955d206f23be91be8a
|
|
BLAKE2b-256 checksum How to use checksums |
31b36bc403f17a7b3e73e3aa983f5c0133f7a7b63ed063ed0a35ba3909070249
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logRelease files / xshieldai_langchain-1.0.1-py3-none-any.whl
| Download URL | xshieldai_langchain-1.0.1-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d13f27a942b6656c093be1bae17c3d6cc2397937c9a77381138b4772a19dde4a
|
|
BLAKE2b-256 checksum How to use checksums |
666faf0cb7d805dcfd2495a2a1b1acd641a3bfb956809f8ad3cadcc5bf65d033
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency log