An agent running in AWS Lambda looks, from the outside, like a handler function: def handler(event, context), called by whatever triggered it. If that handler lets a model decide to write to a database or call an internal API, it needs the same authorization boundary as any other agent.
The INTREXA AXIS SDK (agf-sdk) has no Lambda-specific adapter. Its guard_tool decorator already works on a plain (event, context) handler, and a regression test runs it through the call shape of the real Lambda runtime interface client. This post is about what is different in Lambda, and about what a guard on a handler does and does not decide. For the setup, see the AXIS AWS Lambda guide.
What changes when an agent runs in Lambda
Containers are reused. One container can serve many invocations before AWS recycles it, and module-level state, including an AGF client, persists across them. That is normally a performance win. It is also why the SDK version matters: before agf-sdk 0.7.0, a client shared across calls could fail on its second synchronous guarded call, which is exactly the pattern a warm container produces. The 0.7.0 release post has the root cause. Pin agf-sdk >= 0.7.0 in any deployment that reuses a client.
Delegation chains are short-lived. In the documented pattern, the agent signs its own delegation chain with its private key, and a chain built that way expires after five minutes. A warm container can sit idle for longer than that, so the chain has to be built for each invocation, not once at start-up. That is what the chain_provider argument is for.
The key has to be stable. The agent's keypair is created once, its public half is registered for that agent, and the same private key signs every chain. A new keypair at every start would sign chains with a key the runtime has not registered, and the documented result is a DENY, not an error, which can look like a legitimate decision. Where you keep the private key, and how the function loads it, is part of your deployment.
What the guard decides, and what it doesn't
guard_tool asks for a decision using:
- the action type you give it, for example
lambda:issue_refund; - the resource, which is the function's name unless you set one (for a Lambda handler that is usually
handler); - the delegation chain;
- the agent id, as audit context.
By default it does not look at the event. Guarding lambda:issue_refund tells you whether this agent may perform that action. It does not tell you whether this particular refund, for this amount, is acceptable. A call-level decision needs the relevant fields passed to the decision explicitly and a policy that evaluates them. From agf-sdk 0.11.0, guard_tool can do the first part if you opt in: a context_provider returns selected fields from the call's arguments, limited to a required allowlist, and they are sent with the decision request. The second part is still yours: the field changes a decision only if your active policy reads it, and a value such as an amount is declared by your handler, not verified. The AXIS AWS Lambda guide has the example.
When the decision is DENY or REVIEW_REQUIRED, the guard raises AGFDeniedError or AGFReviewRequiredError out of the handler before your code runs. What Lambda does with an uncaught exception depends on your function's error handling.
Where the guard sits relative to your observability decorators
If your handler already uses logging or tracing decorators, the guard's position changes what they see. We tested AWS Lambda Powertools 3.38.0: the Logger decorator, and the Tracer decorator with a recording provider standing in for X-Ray.
- With the guard innermost, closest to
def handler, its policy call runs inside those decorators, so anything it logs carries the Lambda context fields, and a denial it raises reaches the Tracer decorator, which records the error. - With the guard outermost, neither is true: the policy call happens before those decorators run, so its logs lack that context, and a denial is raised before the Tracer opens its span.
Either way, the guard received the original event and context objects. We did not test a live X-Ray daemon, or how the Metrics decorator handles a raised exception.
What this does not do
A guard on a handler governs whether an agent may take an action; eligible decisions can produce decision evidence. It does not make a model's output correct or safe, by default it does not evaluate the contents of the event (the opt-in context above sends only the fields you choose), and it does not replace the other controls on the function. Layer it with them.
Next steps
- AXIS AWS Lambda guide: the handler example, the decorator stack and the setup.
- agf-sdk 0.7.0 release: the warm-container fix in detail.
- MCP gateway integration: the
guard_toolpattern this reuses.
The INTREXA AXIS SDK (agf-sdk) is open source. GitHub →

