Separating an AI agent from a Lambda tool handler

For an application where an AI agent can call backend tools, I would keep each Lambda handler limited to one operation with explicit input validation. The model can propose an action, but the handler should still check authorization for the current user. I would require a separate approval step for destructive operations.

Evgenii Arsentev writes about the distinction between agents and chatbots here: What Is an AI Agent? Agents vs Chatbots, Explained. This is background reading, rather than a Serverless Framework deployment tutorial.

For longer tasks, would you put the orchestration in Step Functions and use Lambda only for individual tool calls? I would be interested in how others separate retries from actions that must not run twice.

Step Functions for orchestration with Lambda only for individual tool calls is a good split. For retries, make each tool handler idempotent by taking an idempotency key from the caller and storing it in DynamoDB with a conditional write, so a retried call returns the saved result instead of running again. Let Step Functions own the retry policy (Retry with backoff and MaxAttempts) and only retry on errors you know are transient, like throttling. For destructive actions, put a manual approval step in front using a task token (waitForTaskToken), and send failures to an SQS dead-letter queue so nothing is silently replayed.