Metadata-Version: 2.4
Name: behavry-langchain
Version: 0.5.1
Summary: Behavry integration for LangChain and LangGraph agents: governed MCP tools with a signed record of every call
License: Apache-2.0
Author: Behavry
Author-email: pypi@behavry.ai
Requires-Python: >=3.10,<4.0
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: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Provides-Extra: mcp
Requires-Dist: httpx (>=0.27,<1.0)
Requires-Dist: langchain-core (>=1.0,<2.0)
Requires-Dist: langchain-mcp-adapters (>=0.3.2,<0.4) ; extra == "mcp"
Description-Content-Type: text/markdown

# behavry-langchain

Behavry integration for LangChain and LangGraph agents.

Load your agent's MCP tools through the Behavry MCP gateway, so every tool call is bound to the agent's identity, evaluated against policy, and written to the signed record before it reaches the target system.

```bash
pip install "behavry-langchain[mcp]"
```

```python
from langchain.agents import create_agent
from behavry_langchain import behavry_mcp_tools

tools = await behavry_mcp_tools()          # reads BEHAVRY_PROXY_URL / _CLIENT_ID / _CLIENT_SECRET
agent = create_agent("anthropic:claude-sonnet-5", tools)
```

What the helper handles for you:

- **Auth that lasts the whole run.** It authenticates with the agent's client credentials (HTTP Basic), which the gateway exchanges server-side on every request, so nothing expires partway through a long run.
- **Refusals the model can read.** When policy blocks a call, the agent gets an error tool result explaining why, instead of the run crashing.
- **Calls held for approval.** When policy holds a call for a person to approve, the gateway answers "pending" within a minute and the helper resends the identical call until it is decided. The call runs once, when approved, and the agent gets its real result, however long the approval takes.
- **Workflow sessions.** If the run belongs to a declared Behavry workflow, pass the session's `wf_token` (`workflow_token=...` or `with workflow_session(wf_token):`) and the calls are grouped into that workflow's Decision Trace.
- **A `behavry:governed` tag on every tool**, so agent-side reporting can tell these calls are already recorded by the gateway.

Local Python tools never reach Behavry. Report them with one line; they are recorded as **Agent-reported** (signed, not enforced), and by default only hashes and sizes of their input and output leave your process:

```python
from behavry_langchain import BehavryCallbackHandler

handler = BehavryCallbackHandler()
agent.invoke(inputs, config={"callbacks": [handler]})
```

Full guide: [`docs/integrations/langchain.md`](../../docs/integrations/langchain.md).

License: Apache-2.0.

