Skip to main content
The AtlaSent LangChain integration wraps your tool functions with authorize-first semantics: each tool call is evaluated and its permit verified through AtlaSent before the underlying function runs. If authorization does not succeed, the tool does not execute. It works with any LangChain tool factory and has no dependency on langchain itself.

Install

Not yet published. atlasent-langchain is not yet on PyPI and @atlasent/langchain is not yet on npm, so the install commands below do not work yet. Until a release is published, install from source: python/atlasent_langchain and typescript/packages/langchain in the atlasent-sdk repository.

Python

Wrap the callable, then hand the wrapped function to LangChain’s @tool, StructuredTool.from_function, or any other tool factory:
Use async_with_langchain_guard with an AsyncAtlaSentClient for async tools.

TypeScript

What the guard does

  • Before each tool call, evaluates the call through AtlaSent and verifies the resulting permit.
  • Sends the tool’s name as context.tool and the call’s input as part of the evaluated context.
  • Runs the tool only if authorization succeeds. Otherwise it raises AtlaSentDeniedError (the default), or — with on_deny="tool-result" (Python) / onDeny: "tool-result" (TypeScript) — returns a structured denial instead, so the model can see the reason and adapt its plan. The tool still does not run.
  • When the tool returns a JSON object, annotates it with _atlasent_permit_id and _atlasent_audit_hash, linking the result to the audit chain.

Action type and required context

By default every call is evaluated as the canonical agent.tool.invoke action. That action class requires the tool and environment context inputs: the guard supplies tool, and you supply environment (via extra_context / extraContext) — the guard never invents one. Action classes also require a state snapshot by default; pass state_snapshot / stateSnapshot (for example {"source": "my-agent", "complete": true}) or calls are denied with SNAPSHOT_REQUIRED. To gate a tool under a different action type, pass action. Map tools to stable action types that match your AtlaSent policy — don’t use the Python function name, which couples regulatory meaning to code refactors.