Skip to main content

xat-langchain

XAT signing for LangChain. Every tool call gets an Agent-Signature header.

Based on the x-agent-trust extension in the OpenAPI Extensions Registry.

Install

pip install xat-langchain

Usage

Wrap existing tools

from xat_langchain import XATToolkit

toolkit = XATToolkit(key_file="agent.pem", agent_id="my-agent")
signed_tools = toolkit.wrap(existing_tools)

# Every HTTP call these tools make now carries Agent-Signature
agent = create_react_agent(llm, signed_tools)

Decorator

from xat_langchain import xat_tool
import requests

@xat_tool(key_file="agent.pem", agent_id="my-agent")
def search(query: str) -> str:
    return requests.get(f"https://api.example.com/search?q={query}").text

With AWS KMS (production)

import boto3

kms = boto3.client("kms", region_name="eu-west-2")

async def kms_sign(data: bytes) -> bytes:
    import hashlib
    digest = hashlib.sha256(data).digest()
    response = kms.sign(
        KeyId="arn:aws:kms:eu-west-2:123456:key/abcd",
        Message=digest,
        MessageType="DIGEST",
        SigningAlgorithm="ECDSA_SHA_256"
    )
    return response["Signature"]

toolkit = XATToolkit(kms_sign=kms_sign, agent_id="prod-agent")

Audit trail

from xat_langchain import XATCallbackHandler

handler = XATCallbackHandler()
agent.invoke({"input": "..."}, config={"callbacks": [handler]})
print(handler.signed_calls)

What it does

  • Wraps LangChain tool HTTP calls with automatic Agent-Signature signing
  • ECDSA P-256 (ES256) over a canonical request string
  • Private key never enters memory when using KMS providers
  • Works with any LangChain tool that makes HTTP requests

Links

Author

Raza Sharif, CyberSecAI Ltd

License

Apache-2.0

Release files for xat-langchain 0.1.0

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

Source distribution (sdist)

Source distribution for xat-langchain 0.1.0
File Size Uploaded
xat_langchain-0.1.0.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xat-langchain 0.1.0
File Interpreter ABI Platform
xat_langchain-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / xat_langchain-0.1.0.tar.gz

Download URL xat_langchain-0.1.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d49439b81f1763984a380cb2e8d1f2ecef8f597bae5710b855328f6cd9fa4fbf
BLAKE2b-256 checksum
How to use checksums
7ebb9b70ad0a616fbfa0a02a1dcadc82611ec575becdbec9163ea97248ed9536
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / xat_langchain-0.1.0-py3-none-any.whl

Download URL xat_langchain-0.1.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa60bdbe7fc3c949a21c0ef302a01bdc8907be4c193f9f78de0c3e708150c626
BLAKE2b-256 checksum
How to use checksums
a1faeca01a1d7338cd5bd7f76f992845812ae5acba2149bab60a8f883565a088
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

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