Ory Agent Security for LangChain / LangGraph — per-tool authorization, tracing, and identity propagation via an AgentMiddleware. Built on ory-argus.
Project description
ory-langchain
Ory Agent Security for LangChain / LangGraph.
Adds three things to a LangChain agent with one line:
- Authorization — every tool call is checked against Ory Permissions before it runs.
- Tracing — every invocation is recorded as a structured span (OTLP + NDJSON).
- Identity propagation — user → agent → sub-agent delegation, recorded in Ory.
Install
pip install ory-langchain
Use
from langchain.agents import create_agent
from ory_langchain import OryMiddleware
agent = create_agent(
model,
tools=[search, send_email],
middleware=[OryMiddleware()], # gate every tool call through Ory
)
OryMiddleware() reads the shared Ory config at ~/.config/ory-agent-plugins/config.json,
so a login performed by any Ory coding-agent harness — or by ory-argus login — is reused
transparently. Configure a project explicitly with OryMiddleware(project_url=...).
Permission mode
observe(default) — denied tools still run, but apermission.observe_denyspan is recorded. Use this to see what would be blocked before enforcing.enforce— denied tools are blocked: the model receives an errorToolMessageand the tool never executes. SetORY_PERMISSION_MODE=enforceor runory-argus permissions enforce.
Tracing only
If you only want observability (no enforcement), use the callback handler instead:
from ory_langchain import OryCallbackHandler
agent.invoke({"messages": [...]}, config={"callbacks": [OryCallbackHandler()]})
Built on ory-argus, the shared Ory Agent Security core.
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 Distributions
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 ory_langchain-0.11.1-py3-none-any.whl.
File metadata
- Download URL: ory_langchain-0.11.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73ee1e510252aaed25ed7ad675bb4c1b7675293c4d6e52a3f8257359837bfb5f
|
|
| MD5 |
7e28a45e684d92ab38ee8ad696d98ccd
|
|
| BLAKE2b-256 |
1fb17aa5d0dd37525d11dfb3e688fa428e3d934c905b5b62edc748a6669ef108
|