Lesson 4 of 5 Multi-Agent Systems and Agent Safeguards

Building Human-in-the-Loop Review and Feedback

This lesson covers review and approval workflows and feedback collection that combine model speed with human judgement at defined points, for decisions too risky, uncertain or regulated to leave entirely to a model.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose a human augmentation pattern.
  • Implement approval with the .waitForTaskToken integration pattern.
  • Collect and use user feedback.

Human augmentation patterns

Common patterns include approval before action, where an agent proposes an irreversible action such as a refund above a threshold and a person approves it; review of low-confidence outputs, where only outputs below a confidence threshold go to a reviewer; draft and edit, where the FM drafts and an expert edits and sends; escalation, where the agent hands the conversation to a human agent with a summary; and sampling audits, where a percentage of outputs is reviewed to measure quality.

Match the pairs

Human-in-the-loop patterns

Exam skills 2.1.5

Match each human-in-the-loop pattern with an example.

Log in to try this activity Interactive activities are free with an account.

Review and approval with Step Functions

Step Functions implements approval with the .waitForTaskToken service integration pattern. The workflow reaches a Task state that, for example, sends a message through Amazon SNS or writes a review item to DynamoDB, including a task token. The execution pauses, without consuming compute, until the review application calls SendTaskSuccess with the token and the decision, or SendTaskFailure to reject. A TimeoutSeconds value escalates or cancels if nobody responds in time. Callbacks are available in Standard workflows.

"RequestApproval": {
  "Type": "Task",
  "Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken",
  "Parameters": {
    "QueueUrl": "https://sqs.eu-west-1.amazonaws.com/111122223333/refund-approvals",
    "MessageBody": {"proposal.$": "$.proposal", "taskToken.$": "$$.Task.Token"}
  },
  "TimeoutSeconds": 86400,
  "Catch": [{"ErrorEquals": ["States.Timeout"], "Next": "EscalateToSupervisor"}],
  "Next": "ExecuteRefund"
}

Amazon Augmented AI (A2I) provides managed human review workflows: a flow definition sets the review conditions and worker task template, and a private, vendor or public workforce reviews items, with results stored in S3.

The following diagram shows the approval path for refunds above a threshold in an agent workflow.

Supervisor approval for high-value refunds in a Standard Step Functions workflow. Refunds of USD 500 or less run automatically. Larger ones go to an approval queue with a task token and wait; the supervisor's tool calls SendTaskSuccess or SendTaskFailure, and a 24-hour timeout escalates. Express workflows cannot wait this long.
The threshold and timeout come from the scenario above.
Put in order

An approval with a task token

Exam skills 2.1.5

Put the steps of a human approval in Step Functions in order.

Log in to try this activity Interactive activities are free with an account.

Collecting feedback

User feedback is the most direct evidence of whether a generative AI application is helping. The user interface collects it when users rate a response, flag an error or submit a correction, and sends it to a feedback endpoint exposed by Amazon API Gateway.

A Lambda function stores each item in DynamoDB or Amazon S3 together with the request ID, prompt version and model, so that feedback can be traced back to the exact interaction and configuration that produced it. The function also publishes metrics, such as the share of negative ratings, to Amazon CloudWatch, where alarms detect sudden drops in quality after a release. Collected feedback then drives evaluation datasets, prompt refinement and the review of failing cases. The following table summarises the feedback mechanisms.

NeedMechanism
Pause for approval and resumeStep Functions .waitForTaskToken with SendTaskSuccess
Managed human review tasks and workforceAmazon Augmented AI
Collect ratings and correctionsAPI Gateway endpoint, Lambda, DynamoDB or S3
Hand off to a human agentEscalation with conversation summary (for example Amazon Connect)
Worked example

High-value refunds

An agent processes refund requests automatically. Company policy requires a supervisor's approval for refunds above USD 500, and approvals can take up to a day.

The refund workflow in a Standard Step Functions workflow checks the amount; above the threshold it sends the proposal with a task token to an approval queue and waits; the supervisor's tool calls SendTaskSuccess or SendTaskFailure; a 24-hour timeout escalates. Express workflows would not work because of the five-minute limit and lack of callback support.

Check yourself

An approval can take several days. Which workflow type is needed?

Show answer

A Standard workflow with a timeout. Express workflows run for at most five minutes.

Exam Tips

Remember for the exam

  • Approve irreversible or high-value actions; review low-confidence outputs.
  • Pause and resume for humans: .waitForTaskToken with SendTaskSuccess or SendTaskFailure.
  • Long human waits need Standard workflows with a timeout.
  • Managed human review workflows and workforces: Amazon A2I.