Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Human in the Loop for AI Agents with Step Functions

Описание и применение

В статье описывается, как с помощью AWS Step Functions и Serverless Framework реализовать безопасный поток утверждения для ИИ‑агента, выдающего клиентским кредитам. Пороговые значения 20 € и 500 € определяют, когда требуется ручное одобрение, а токен задачи защищает от несанкционированного выполнения.

Задача

AI agents that perform costly or irreversible actions need a safety mechanism to involve human approval before execution.

Результат

The workflow ensures that only amounts below 20 € are auto‑credited, larger amounts require human approval, and any attempt to exceed 500 € is blocked. Escalation to a team lead after 4 h protects against missed approvals.

Рабочий процесс

  • 1. Agent calls "request credit" tool, starting a Step Functions execution with order details.
  • 2. Choice rule evaluates amount: auto‑credit up to 20 €, team approval for 20.01–500 €, or stop for >500 €.
  • 3. AskTeam step invokes a Lambda with .waitForTaskToken, stores token in DynamoDB, and publishes an SNS message with approval ID.
  • 4. Human approves or rejects via a signed request to a second Lambda, which retrieves the token and calls SendTaskSuccess or SendTaskFailure.
  • 5. If no response within 4 h, TimeoutSeconds triggers a Catch that routes to AskLead for escalation.
  • 6. If lead also does not respond, workflow ends with ApprovalExpired and no credit is booked.

Доказательства

With the “wait for callback” pattern, Step Functions can wait up to a year for an answer, and the waiting itself costs nothing.

Источник

A task token is a long random string that identifies exactly one waiting step. Anyone who knows it and holds the IAM permission states:SendTaskSuccess can complete the step and pass any data as its result.

Источник

If there is no answer within four hours, TimeoutSeconds kicks in. A Catch routes to the AskLead step, which asks the team lead.

Источник

  • Дата записи: 2026-11-03T10:43:46.168Z