Agent Governance Foundation

Authorizing LangChain Agents: Where the Check Belongs

Agent Governance Foundation
langchainauthorizationarchitectureagent-governance

A LangChain agent decides which tool to call and with what arguments. Before that call runs, something has to decide whether this agent is allowed to make it. The framework gives you places to put that check. It does not decide, for you, what the check should say.

This post is about that design: where authorization can sit in a LangChain agent, what each placement can and cannot see, and what a decision should cover. It is a design guide. If you want the step-by-step setup with AXIS, that is in the AXIS LangChain integration guide.

Why prompts are not the control

A system prompt that says "never run shell commands" is guidance. The model can be wrong, confused, or steered by text it reads in a web page or a file. If the only thing between an agent and an action is the agent's own judgement, that judgement is the control, and it is the part that fails when an agent is manipulated.

An authorization check is different in kind: it runs outside the model's reasoning, before the action, and its answer does not depend on what the model believes it should do.

The four questions every design has to answer

Whatever you build, a useful authorization decision answers four questions:

  1. Who is acting? An identity for the agent itself, not just the credentials of the user who started it.
  2. What authority does it hold? What was delegated to it, by whom, with what limits, and has any of that been revoked or expired.
  3. What is it trying to do? The action, the resource, and the specifics of this call.
  4. What happens next, and what is kept? Allow, deny, or send to a human; and a record of what was decided and why.

The AGF authorization-flow model describes these as agent identity, delegated authority, an action request evaluated by a policy decision point (PDP), and decision evidence. These are standards concepts, and the AGF specifications are published as Working Drafts. How much of this a product implements, and how closely it conforms, depends on the specification and the product. Where it matters, we say what AXIS does.

Where can the check go in a LangChain agent?

LangChain's guardrails documentation describes two kinds of check, deterministic rules and model-based classifiers, and says they are applied through middleware around the agent run. It also ships a human-in-the-loop middleware that pauses the agent for approval on the tools you list. Its custom-middleware documentation shows a wrap_tool_call hook that receives the tool name and arguments for each call and decides whether the call proceeds.

That gives you a few placements. They answer different questions, and they combine.

| Placement | What it can see | What it is good for | What it leaves to you | |---|---|---|---| | System prompt | Nothing enforced | Steering behaviour | Everything: it is not a control | | Framework middleware (wrap_tool_call) | Tool name and the arguments of each call | An in-process place to run any check, including argument-level ones | The decision itself: identity, delegation, policy, revocation, audit all come from your code or a service | | Human-in-the-loop middleware | Which tools you configured for approval | Putting a person in front of named, high-stakes tools | Deciding by actor, context or risk: approval is configured per tool | | Tool wrapper | The wrapped tool, wherever it is used | A check that travels with the tool across agents and frameworks | Per-call detail, unless the wrapper passes it to the decision | | External gateway | Traffic crossing a boundary | Tools the agent reaches over a protocol (see our MCP post) | In-process detail |

The useful reading of this table: hooks answer where a check runs, and a policy decision point answers what the check decides. LangChain's hooks are a good place to call a decision service. They are not a substitute for having one, and a decision service has no way to intercept a LangChain tool call without a hook or wrapper to call it from. Treat them as two halves, not rivals.

In AXIS: the INTREXA AXIS SDK takes the tool-wrapper route. AGFGuardedTool wraps a LangChain BaseTool, covers both the sync and async paths, and asks the AXIS decision service before the wrapped tool runs.

A check the agent can skip is not a control

There are two ways to involve an agent in its own authorization.

In an advisory design, the agent gets an authorization tool and is expected to call it before sensitive operations. That is useful: the agent can reason about the answer, and you can see the exchange in its trace. But the decision to ask belongs to the model. Anything that can change what the model does, including injected text, can change whether it asks. And the check only sees what the agent reports: in the AXIS gate tool the agent supplies the action and resource itself, so the answer is only as accurate as the agent's description of what it is about to do.

In an enforced design, the check wraps the tool. It runs whenever the tool is invoked, whether or not the model asked. Use enforcement for actions with real consequences, and advisory checks where you want the agent to explain or plan around its limits. The two can be combined.

Enforcement has a limit worth stating plainly. It guarantees that the check runs when the tool is called. It does not guarantee the check is specific enough to catch a harmful call to a tool the agent is allowed to use. That depends on what the decision looks at.

In AXIS: by default, AGFGuardedTool decides from the action type and resource you set when you wrap the tool, plus the delegation chain, so it answers "may this agent use this tool?", not "is this particular command acceptable?". From agf-sdk 0.11.0 you can opt in to per-call detail: a context_provider builds context fields from the tool-call arguments, limited to a required allowlist of keys, and they are sent with the decision request. Three limits matter. A supplied value such as an amount is declared by the caller, not verified by AXIS. A decision depends on a field only if the active policy reads it. And the context is included in the signed artifact's request block, to which the runtime may add its own fields, so it must never carry secrets or personal data. The setup, with an example, is in the AXIS LangChain integration guide.

How specific should the decision be?

Think of four levels, from coarse to fine:

  1. Tool-level: may this agent use a shell tool at all?
  2. Action and resource: may it write to this location, call this API?
  3. Call-level: is this command, this amount, this recipient acceptable? This needs the call's arguments and context in the decision.
  4. Execution-time: is the decision still valid at the moment of dispatch?

The fourth level is easy to miss. A decision is made at one moment. If the tool runs later, because of a queue or a long-running agent, the agent may have been revoked or its authority may have expired in between. Re-checking just before dispatch closes that gap. In AXIS this is the optional validate_execution setting, covered in the integration guide.

Start with the level that matches the risk. Coarse checks are cheap and catch the large mistakes. Call-level checks need more policy work and are worth it for the actions you cannot undo.

What the decision should leave behind

A decision is only useful later if it is recorded. A good record answers, for any action: who acted, under what delegated authority, what was attempted, what was decided, and under which policy version.

The standards call this decision evidence.

In AXIS: for eligible authorization decisions (ALLOW, DENY or REVIEW_REQUIRED), AXIS builds a decision artifact that records the request, response and policy information. When the request includes an organization ID, the artifact is persisted and can be accessed through the audit, export and verification interfaces. Dry runs, pre-check denials and exceptions can bypass artifact creation.

The shape of an AXIS artifact, heavily trimmed. The values are placeholders and several fields are omitted; this is an illustration, not a complete export:

{
  "artifact_id": "dec_…",
  "schema_version": "1.1",
  "timestamp": 0,
  "agent_id": "did:agf:agt_…",
  "request":  { "delegation_chain": ["…"],
                "action": { "type": "tool:shell", "resource": "shell" },
                "context": { "…": "…" } },
  "response": { "decision": "ALLOW", "reasoning": ["…"] },
  "policy":   { "version": "…" },
  "signatures": [ { "signer": "…", "algorithm": "…", "signature": "…" } ]
}

The signature covers the artifact id, the timestamp, the agent id, and the request, response and policy blocks. Operational metadata, such as the schema version, the verifier id and the revocation state, sits outside it.

The runtime's primary signing path uses ES256. If the signing key is unavailable, the source implements a fallback to HMAC-SHA256 and logs an error. Check each artifact's algorithm field rather than assuming the algorithm. An HMAC signature requires access to the shared secret for verification; it cannot be verified using a public key alone.

A valid signature verifies the covered data against the relevant signing key. It does not establish that the authorization decision was correct or that the action actually executed.

The point of the record is accountability after the fact: when something goes wrong, you can see what was authorized and why, rather than reconstructing it from logs.

Approval: person-in-the-loop versus policy-driven review

LangChain's human-in-the-loop middleware pauses the agent for approval on the tools you list. That is a clear, easy-to-reason-about control. What it keys on is the tool: send_email needs approval, always.

A policy-driven review keys on the decision: the same tool might be allowed for a trusted agent in a test environment, denied for an unverified one, and sent for review in production above a risk threshold. A decision may return ALLOW, DENY or REVIEW_REQUIRED. A review-required outcome routes the action for human review. It is not itself an approval: the action should remain pending until the approval flow resolves it according to the configured review and fallback behavior. Neither approach is better in general. Per-tool approval is simpler. Policy-driven review is for when the answer depends on who is acting and in what context.

In AXIS: a review-required decision creates an approval request that records the agent, the action and resource, the reviewer role required, a timeout and a fallback action (DENY by default), and a link to the decision's artifact. The approval request itself does not store the full decision context; the context sent with the decision is held in the linked artifact. What a reviewer is shown depends on the implementation.

What authorization does not do

Authorization governs what an agent is allowed to do and keeps a record of it. It does not make a model's answers correct or safe. It does not replace input and output guardrails such as content filtering or PII handling. And it does not stop a harmful use of an allowed action unless the policy looks at enough of the call to tell. Layer it with the other controls instead of treating it as the only one.

A sketch: where a call-level check would sit (pseudocode)

This is pseudocode, not tested code. decision_service, agent_identity and blocked_result are placeholders for your own decision client, identity and blocked-call handling. The LangChain parts (create_agent, @wrap_tool_call, request.tool_call) follow LangChain's middleware documentation, but this combined snippet has not been run. It shows where a call-level check would sit in LangChain middleware; it is not the AXIS SDK's API (see the AXIS note above for the opt-in context_provider).

from langchain.agents import create_agent
from langchain.agents.middleware import wrap_tool_call

@wrap_tool_call
def authorize_tool_call(request, handler):
    call = request.tool_call                       # name and args of this call
    decision = decision_service.check(             # your PDP client
        actor=agent_identity,
        action=f"tool:{call['name']}",
        context={"args": call["args"]},            # call-level detail
    )
    if not decision.allowed:
        return blocked_result(call, decision)      # handler is not called
    return handler(request)

agent = create_agent(model=model, tools=tools, middleware=[authorize_tool_call])

The AXIS adapter, with identity, delegation, review handling and audit, is described in the AXIS LangChain integration guide.

Choosing

  • Starting out, or low consequence: a coarse tool-level check on the risky tools, enforced by wrapping them.
  • Actions you cannot undo: add call-level context to the decision and write policy that uses it. Add an execution-time re-check if calls can run later.
  • Mixed trust or several agents: the decision needs identity and delegation, not just a tool list. See the delegation problem and revocation at scale.
  • Where to draw boundaries between trust levels: three trust zones.

The AGF specifications are public. The INTREXA AXIS SDK (agf-sdk) is open source: GitHub →.