langchain itself.
Install
Python
Wrap the callable, then hand the wrapped function to LangChain’s@tool,
StructuredTool.from_function, or any other tool factory:
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.tooland the call’s input as part of the evaluated context. - Runs the tool only if authorization succeeds. Otherwise it raises
AtlaSentDeniedError(the default), or — withon_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_idand_atlasent_audit_hash, linking the result to the audit chain.
Action type and required context
By default every call is evaluated as the canonicalagent.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.
Related
- LlamaIndex integration
- Policy authoring