Skip to main content

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:

  1. Authorization — every tool call is checked against Ory Permissions before it runs.
  2. Tracing — every invocation is recorded as a structured span (OTLP + NDJSON).
  3. 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 a permission.observe_deny span is recorded. Use this to see what would be blocked before enforcing.
  • enforce — denied tools are blocked: the model receives an error ToolMessage and the tool never executes. Set ORY_PERMISSION_MODE=enforce or run ory-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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ory_langchain-0.11.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

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

Hashes for ory_langchain-0.11.1-py3-none-any.whl
Algorithm Hash digest
SHA256 73ee1e510252aaed25ed7ad675bb4c1b7675293c4d6e52a3f8257359837bfb5f
MD5 7e28a45e684d92ab38ee8ad696d98ccd
BLAKE2b-256 1fb17aa5d0dd37525d11dfb3e688fa428e3d934c905b5b62edc748a6669ef108

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page