Metadata-Version: 2.4
Name: langchain-agentoath
Version: 0.1.0
Summary: AgentOath trust protocol integration for LangChain -- automatic trust receipts for chains, tools, and LLM calls.
Author-email: AgentOath Protocol Team <team@agentoath.ai>
License: Apache-2.0
Project-URL: Homepage, https://agentoath.ai
Project-URL: Repository, https://github.com/AgentOath/agentoath
Project-URL: Documentation, https://agentoath.ai/docs/integrations/langchain
Keywords: ai,agent,trust,langchain,agentoath,identity
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: agentoath>=0.2.0
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.1.0; extra == "langchain"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"

# langchain-agentoath

AgentOath trust protocol integration for [LangChain](https://python.langchain.com/).

Automatically generates cryptographically signed trust receipts for every LangChain chain execution, tool call, and LLM interaction.

## Installation

```bash
pip install langchain-agentoath
```

For full LangChain integration (optional):
```bash
pip install langchain-agentoath[langchain]
```

## Quick Start

### Callback Handler -- automatic receipts

```python
from agentoath import TrustAgent
from langchain_agentoath import AgentOathCallbackHandler

# Create an agent identity
agent = TrustAgent.create(name="MyChain", capabilities=["chat"])

# Create the callback handler
handler = AgentOathCallbackHandler(agent)

# Attach to any LangChain chain
result = chain.invoke(
    {"input": "What is the weather?"},
    config={"callbacks": [handler]},
)

# Every chain/tool/LLM event now has a signed receipt
for receipt in handler.receipts:
    print(receipt.action, receipt.rating, receipt.description)
```

### TrustedChain -- wrapper with pre/post receipts

```python
from langchain_agentoath import TrustedChain

trusted = TrustedChain(chain=my_chain, agent=agent)
result = trusted.invoke({"input": "hello"})

# Pre-execution + post-execution + per-step receipts
print(f"Generated {len(trusted.receipts)} trust receipts")
```

### Trust-aware Tools

```python
from langchain_agentoath import VerifyAgentTool, SignReceiptTool, CheckTrustTool

tools = [
    VerifyAgentTool(trust_agent=agent),
    SignReceiptTool(trust_agent=agent),
    CheckTrustTool(trust_agent=agent, min_score=0.7),
]

# Use in any LangChain agent
result = tools[0].run('{"agent_did": "did:trust:agent:abc123"}')
```

### TrustFilteredRetriever -- trust-gated RAG

```python
from langchain_agentoath import TrustFilteredRetriever

retriever = TrustFilteredRetriever(
    base_retriever=my_vector_store.as_retriever(),
    agent=agent,
    min_trust_score=0.6,
)

# Only returns documents from agents with trust score >= 0.6
docs = retriever.get_relevant_documents("important query")
```

## Components

| Component | Description |
|-----------|-------------|
| `AgentOathCallbackHandler` | LangChain callback that auto-creates trust receipts for all events |
| `TrustedChain` | Chain wrapper with pre/post execution receipts |
| `VerifyAgentTool` | LangChain tool to verify agent identity and trust score |
| `SignReceiptTool` | LangChain tool to sign trust receipts |
| `CheckTrustTool` | LangChain tool to check trust before delegation |
| `TrustFilteredRetriever` | Retriever that filters documents by agent trust score |

## License

Apache-2.0
