# Separating an AI agent from a Lambda tool handler

**URL:** <https://forum.serverless.com/t/separating-an-ai-agent-from-a-lambda-tool-handler/22065>\
**Category:** Serverless Architectures\
**Created:** [October 23, 2026, 10:45am UTC](https://forum.serverless.com/t/separating-an-ai-agent-from-a-lambda-tool-handler/22065 "2026-10-23T10:45:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucysilva](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/lucysilva/32/8557_2.png) [@lucysilva](https://forum.serverless.com/u/lucysilva)\
**Post date:** [October 23, 2026, 10:45am UTC](https://forum.serverless.com/t/separating-an-ai-agent-from-a-lambda-tool-handler/22065/1 "2026-10-23T10:45:19Z")

</div>

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](https://arsentev.ai/guides/agents-vs-chatbots). 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.

---

<div class="post-metadata">

**Author:** ![colorfulcms](https://avatars.discourse-cdn.com/v4/letter/c/8491ac/32.png) [@colorfulcms](https://forum.serverless.com/u/colorfulcms)\
**Post date:** [October 26, 2026, 12:13pm UTC](https://forum.serverless.com/t/separating-an-ai-agent-from-a-lambda-tool-handler/22065/2 "2026-10-26T12:13:27Z")

</div>

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.
