LangChain callback handler for EXIT Protocol departure markers
Project description
exit-door-langchain 𓉸
𓉸 Passage Protocol · exit-door · entry-door · mcp · langchain · vercel · eliza · eas · erc-8004 · sign · python
⚠️ Pre-release software -- no formal security audit has been conducted.
LangChain callback handler for EXIT Protocol departure markers. Automatically creates signed departure records when chains or agents complete execution. Thread-safe, fail-safe, works with LCEL and LangGraph.
Quick Start
pip install exit-door-langchain
from exit_door_langchain import ExitCallbackHandler
handler = ExitCallbackHandler(origin="my-app")
# Use with any LangChain chain
chain.invoke({"input": "hello"}, config={"callbacks": [handler]})
# Markers are collected automatically
print(handler.markers[-1].id) # urn:exit:abc123...
Configuration
from exit_door import ExitType
handler = ExitCallbackHandler(
origin="my-platform", # Platform name (default: "langchain")
exit_type=ExitType.VOLUNTARY, # Exit type for success (default: VOLUNTARY)
error_exit_type=ExitType.FORCED, # Exit type for errors (default: FORCED)
on_marker=my_callback, # Called on each new marker
max_markers=500, # Memory limit (default: 1000)
root_only=True, # Skip subchain markers (default: True)
fail_safe=True, # Never break user's chain (default: True)
)
API
| Method / Property | Description |
|---|---|
handler.markers |
Deque of collected ExitMarker objects |
handler.markers_to_json() |
Export all markers as JSON array |
handler.clear() |
Remove all stored markers and reset state |
How It Works
The handler hooks into LangChain's callback system:
| Callback | When | Exit Type |
|---|---|---|
on_chain_end |
Chain completes successfully | exit_type (default: VOLUNTARY) |
on_chain_error |
Chain fails with exception | error_exit_type (default: FORCED) |
on_agent_finish |
Agent completes (deduplicated) | exit_type (default: VOLUNTARY) |
root_only mode (default): Only creates markers for root-level chain completions, not nested subchains. Set root_only=False to get a marker for every chain/subchain.
fail_safe mode (default): Marker creation errors are logged but never propagated to the user's chain. Set fail_safe=False to let exceptions bubble up.
Thread safety: Safe for concurrent chain invocations sharing one handler instance.
Web Server Usage
In web server contexts, create a new handler per request to prevent marker accumulation across users:
@app.post("/chat")
async def chat(request: ChatRequest):
handler = ExitCallbackHandler(origin="my-api")
result = chain.invoke(request.input, config={"callbacks": [handler]})
return {"result": result, "departures": len(handler.markers)}
Ecosystem
| Package | Language | Description |
|---|---|---|
| exit-door | TypeScript | Core protocol (reference impl) |
| exit-door | Python | Core protocol |
| cellar-door-entry | TypeScript | Arrival/entry markers |
| @cellar-door/langchain | TypeScript | LangChain integration |
| exit-door-langchain | Python | LangChain integration ← you are here |
| @cellar-door/vercel-ai-sdk | TypeScript | Vercel AI SDK |
| @cellar-door/mcp-server | TypeScript | MCP server |
| @cellar-door/eliza | TypeScript | ElizaOS plugin |
| @cellar-door/eas | TypeScript | EAS attestation anchoring |
| @cellar-door/erc-8004 | TypeScript | ERC-8004 identity/reputation |
| @cellar-door/sign-protocol | TypeScript | Sign Protocol attestation |
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
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 exit_door_langchain-0.1.0.tar.gz.
File metadata
- Download URL: exit_door_langchain-0.1.0.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba8ab9fb60806b7abfd6e3f84152848be8e83497faf5ad7d51d66bf40748967d
|
|
| MD5 |
1f80ed774883c1a2a9f98f351a7c4af1
|
|
| BLAKE2b-256 |
d94f9b3e7481a8fc69494e688f982836a6ec27823877616fa496e93c690faa7f
|
File details
Details for the file exit_door_langchain-0.1.0-py3-none-any.whl.
File metadata
- Download URL: exit_door_langchain-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04e84d4ade5467dc3d629ce9796b2ab84726f45e809ffbc811789096f7f61494
|
|
| MD5 |
c33921af9b7500087def9bd89e350c3b
|
|
| BLAKE2b-256 |
df4542ed795bb2d3e00b68d026a8f0af7700bc7a4db5437a53743a6de23efa1a
|