F.A.I.L. Kit adapter for LangChain agents - Receipts, auditing, and policy enforcement
Project description
fail-kit-langchain
v1.5.0 - LangChain adapter for F.A.I.L. Kit (Python)
Drop-in adapter for integrating LangChain agents with the F.A.I.L. Kit audit framework.
Installation
pip install fail-kit-langchain
With FastAPI support:
pip install fail-kit-langchain[fastapi]
With LangGraph support:
pip install fail-kit-langchain[langgraph]
All extras:
pip install fail-kit-langchain[all]
Quick Start
from fastapi import FastAPI
from langchain.agents import AgentExecutor
from fail_kit_langchain import (
create_fail_kit_endpoint,
ReceiptGeneratingTool
)
app = FastAPI()
# Define tools with automatic receipt generation
class EmailTool(ReceiptGeneratingTool):
name = "email_sender"
description = "Send an email"
def _execute(self, to: str, subject: str, body: str):
send_email(to, subject, body)
return {"status": "sent", "message_id": "msg_123"}
# Create agent
tools = [EmailTool()]
agent_executor = AgentExecutor(agent=agent, tools=tools)
# Add F.A.I.L. Kit endpoint
app.include_router(
create_fail_kit_endpoint(agent_executor),
prefix="/eval"
)
Features
- ✅ Automatic receipt generation from tool executions
- ✅ Full RECEIPT_SCHEMA.json compliance
- ✅ Native LangGraph support
- ✅ Async/await support
- ✅ Custom metadata in receipts
- ✅ Error handling with failure receipts
- ✅ SHA256 hashing for verification
API Reference
create_fail_kit_endpoint(agent_executor, config=None)
Creates a FastAPI router with the /run endpoint.
Parameters:
agent_executor: LangChain AgentExecutor instanceconfig: Optional FailKitConfig
Returns: APIRouter
ReceiptGeneratingTool
Base class for tools with automatic receipt generation.
Methods:
_execute(*args, **kwargs): Override with your tool logicget_receipts(): Get all receiptsclear_receipts(): Clear receipt history
extract_receipts_from_agent_executor(executor, result, config=None)
Extract receipts from AgentExecutor intermediate steps.
wrap_tool_with_receipts(tool)
Wrap a legacy LangChain tool to generate receipts.
Examples
See examples/langchain-python/ for a complete working example.
Testing
pytest
Related
- @fail-kit/core - Core receipt generation library (npm)
- F.A.I.L. Kit CLI - Command-line audit tool
- F.A.I.L. Kit VS Code Extension - IDE integration
License
MIT License - See LICENSE
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fail_kit-1.5.0.tar.gz.
File metadata
- Download URL: fail_kit-1.5.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc23790a00b45906b415f542f4d2df2ead93a16e69985e7c9e83029cc0ae1234
|
|
| MD5 |
4424f902337d14d4d664683c66388350
|
|
| BLAKE2b-256 |
bdec06c5d1663766eb80cb5721114404aadc7ee30db68e9c6fb949c80215cfdb
|
File details
Details for the file fail_kit-1.5.0-py3-none-any.whl.
File metadata
- Download URL: fail_kit-1.5.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9270a62f09ba9d359159b41ba1d1ad5bd278fb7855f4227a7f02771bd53cb16
|
|
| MD5 |
3167c6b19f2b2dfb0436b760622f9809
|
|
| BLAKE2b-256 |
7dbe7970acc0728f4e0f3e0a0503117b5f584aa75a792b530e8e8e3cd28f36d1
|