AWS Builder Center

Workflow-Level SLOs for AI Agents on AWS Implementing the Compounding Reliability Math with Step Functions, CloudWatch, and the agentsre Framework

The math published this week changed how I think about AI agent architecture on AWS. At 95% per-step accuracy, a 10-step agent workflow succeeds only 60% of the time. At 20 steps, 36%. And in reality steps aren't independent an incorrect output at step 2 feeds into step 3, which breaks everything else. Compounding is worse in practice than the raw multiplication suggests.

Senior DevOps & SRE | IEEE Senior Member | AI Observability & Cloud Resilience

The math published this week changed how I think about AI agent architecture on AWS.
At 95% per-step accuracy, a 10-step agent workflow succeeds only 60% of the time. At 20 steps, 36%. And in reality steps aren't independent — an incorrect output at step 2 feeds into step 3, which breaks everything else. Compounding is worse in practice than the raw multiplication suggests.
This article implements the SRE response to that math using AWS-native services: Step Functions for checkpointed workflow execution, CloudWatch for workflow-level SLO tracking, Lambda for intermediate validation, and the agentsre library for DQR and RTD measurement at the workflow level.
Why Step Functions Is the Right Tool Here
Step Functions gives you three properties that matter specifically for the compounding failure problem:
State persistence between steps — if step 4 needs to know what step 2 found, Step Functions carries that forward without the agent having to re-retrieve it. Re-retrieval is a hidden reliability cost that adds effective steps to your workflow.
Native retry with backoff per state — you can configure retry behavior at the step level without routing it through the agent's reasoning. The agent doesn't need to know a retry happened. This keeps RTD clean.
Error catching per state — you can define different failure paths for different step failures. A step 3 failure in an incident investigation workflow should trigger different recovery than a step 7 failure.
The Architecture
EventBridge (incident alert)
→ Step Functions state machine
├── State 1: Pre-execution gate (agentsre PreActionSREGate)
├── State 2: Context retrieval (Bedrock KB)
├── Checkpoint A: Validate retrieved context (Lambda)
├── State 3: Initial hypothesis (Bedrock Claude)
├── State 4: Signal validation (CloudWatch Metrics API)
├── Checkpoint B: Validate hypothesis quality (Lambda + DQR check)
├── State 5: Causal chain evaluation (Bedrock Claude)
├── State 6: Remediation proposal (Bedrock Claude)
├── Checkpoint C: Pre-action gate (agentsre PreActionSREGate)
└── State 7: Execute or escalate (Lambda)
→ RTD trace emitted to CloudWatch Logs
→ WRB metric updated to CloudWatch
→ DynamoDB audit trail updated
Seven states. Three checkpoints. The checkpoints break the compounding chain before errors propagate.
The Step Functions State Machine Definition
python
import boto3
import json

sfn = boto3.client('stepfunctions', region_name='us-east-1')

WORKFLOW_DEFINITION = {
"Comment": "AI SRE Incident Investigation — Checkpointed for Compound Failure Prevention",
"StartAt": "PreExecutionGate",
"States": {

"PreExecutionGate": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:ACCOUNT:function:sre-pre-action-gate",
"Parameters": {
"agent_id.$": "$.agent_id",
"intended_action": "incident-investigation",
"service_scope.$": "$.affected_services"
},
"ResultPath": "$.gate_result",
"Next": "CheckGateApproval",
"Catch": [{
"ErrorEquals": ["States.ALL"],
"ResultPath": "$.error",
"Next": "EscalateToHuman"
}]
},

"CheckGateApproval": {
"Type": "Choice",
"Choices": [{
"Variable": "$.gate_result.approved",
"BooleanEquals": True,
"Next": "RetrieveContext"
}],
"Default": "EscalateToHuman"
},

"RetrieveContext": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:ACCOUNT:function:sre-context-retrieval",
"Parameters": {
"incident_id.$": "$.incident_id",
"service_name.$": "$.service_name",
"alert_signals.$": "$.alert_signals"
},
"ResultPath": "$.context",
"Retry": [{
"ErrorEquals": ["Lambda.ServiceException"],
"IntervalSeconds": 2,
"MaxAttempts": 2,
"BackoffRate": 2.0
}],
"Next": "CheckpointA_ValidateContext",
"Catch": [{
"ErrorEquals": ["States.ALL"],
"ResultPath": "$.error",
"Next": "EscalateToHuman"
}]
},

"CheckpointA_ValidateContext": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:ACCOUNT:function:sre-checkpoint-validator",
"Parameters": {
"checkpoint_id": "A",
"content.$": "$.context",
"required_fields": ["runbook_match", "historical_incidents", "service_topology"],
"agent_id.$": "$.agent_id",
"incident_id.$": "$.incident_id"
},
"ResultPath": "$.checkpoint_a",
"Next": "CheckCheckpointA"
},

"CheckCheckpointA": {
"Type": "Choice",
"Choices": [{
"Variable": "$.checkpoint_a.passed",
"BooleanEquals": True,
"Next": "FormHypothesis"
}],
"Default": "RetryContextRetrieval"
},

"RetryContextRetrieval": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:ACCOUNT:function:sre-context-retrieval-extended",
"Comment": "Second attempt with broader search — RTD increments here",
"Parameters": {
"incident_id.$": "$.incident_id",
"service_name.$": "$.service_name",
"retry": True
},
"ResultPath": "$.context",
"Next": "FormHypothesis",
"Catch": [{
"ErrorEquals": ["States.ALL"],
"Next": "EscalateToHuman"
}]
},

"FormHypothesis": {
"Type": "Task",
"Resource": "arn:aws:states:::bedrock:invokeModel",
"Parameters": {
"ModelId": "anthropic.claude-sonnet-4-6",
"Body": {
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 1000,
"messages": [{
"role": "user",
"content.$": "States.Format('Form a root cause hypothesis for incident {} on service {}. Context: {}', $.incident_id, $.service_name, States.JsonToString($.context))"
}]
}
},
"ResultPath": "$.hypothesis",
"Next": "ValidateSignals"
},

"ValidateSignals": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:ACCOUNT:function:sre-signal-validator",
"Parameters": {
"hypothesis.$": "$.hypothesis",
"service_name.$": "$.service_name",
"time_window_minutes": 30
},
"ResultPath": "$.signal_validation",
"Next": "CheckpointB_ValidateHypothesis"
},

"CheckpointB_ValidateHypothesis": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:ACCOUNT:function:sre-checkpoint-validator",
"Parameters": {
"checkpoint_id": "B",
"content.$": "$.hypothesis",
"signal_validation.$": "$.signal_validation",
"min_confidence": 0.70,
"agent_id.$": "$.agent_id",
"incident_id.$": "$.incident_id"
},
"ResultPath": "$.checkpoint_b",
"Next": "CheckCheckpointB"
},

"CheckCheckpointB": {
"Type": "Choice",
"Choices": [{
"Variable": "$.checkpoint_b.passed",
"BooleanEquals": True,
"Next": "EvaluateCausalChain"
}],
"Default": "EscalateToHuman"
},

"EvaluateCausalChain": {
"Type": "Task",
"Resource": "arn:aws:states:::bedrock:invokeModel",
"Parameters": {
"ModelId": "anthropic.claude-sonnet-4-6",
"Body": {
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 1200,
"messages": [{
"role": "user",
"content.$": "States.Format('Evaluate causal chain for hypothesis: {}. Signal validation: {}', States.JsonToString($.hypothesis), States.JsonToString($.signal_validation))"
}]
}
},
"ResultPath": "$.causal_chain",
"Next": "ProposeRemediation"
},

"ProposeRemediation": {
"Type": "Task",
"Resource": "arn:aws:states:::bedrock:invokeModel",
"Parameters": {
"ModelId": "anthropic.claude-sonnet-4-6",
"Body": {
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 800,
"messages": [{
"role": "user",
"content.$": "States.Format('Propose specific remediation for: {}', States.JsonToString($.causal_chain))"
}]
}
},
"ResultPath": "$.remediation_proposal",
"Next": "CheckpointC_PreActionGate"
},

"CheckpointC_PreActionGate": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:ACCOUNT:function:sre-pre-action-gate",
"Comment": "Final gate before any remediation action executes",
"Parameters": {
"agent_id.$": "$.agent_id",
"intended_action.$": "$.remediation_proposal.action",
"service_scope.$": "$.affected_services"
},
"ResultPath": "$.final_gate",
"Next": "CheckFinalGate"
},

"CheckFinalGate": {
"Type": "Choice",
"Choices": [{
"Variable": "$.final_gate.approved",
"BooleanEquals": True,
"Next": "ExecuteRemediation"
}],
"Default": "EscalateToHuman"
},

"ExecuteRemediation": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:ACCOUNT:function:sre-remediation-executor",
"Parameters": {
"incident_id.$": "$.incident_id",
"remediation.$": "$.remediation_proposal",
"audit_context.$": "$"
},
"ResultPath": "$.execution_result",
"Next": "EmitWorkflowTrace"
},

"EscalateToHuman": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:ACCOUNT:function:sre-human-escalation",
"Parameters": {
"incident_id.$": "$.incident_id",
"escalation_context.$": "$",
"reason": "Pre-action gate blocked or checkpoint validation failed"
},
"Next": "EmitWorkflowTrace"
},

"EmitWorkflowTrace": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:ACCOUNT:function:sre-trace-emitter",
"Comment": "Emit RTD trace and update WRB metric regardless of outcome",
"Parameters": {
"workflow_execution.$": "$"
},
"End": True
}
}
}

def deploy_workflow(state_machine_name: str,
role_arn: str) -> dict:
"""Deploy the checkpointed SRE investigation state machine."""
response = sfn.create_state_machine(
name=state_machine_name,
definition=json.dumps(WORKFLOW_DEFINITION),
roleArn=role_arn,
type='STANDARD',
loggingConfiguration={
'level': 'ALL',
'includeExecutionData': True,
'destinations': [{
'cloudWatchLogsLogGroup': {
'logGroupArn': (
f'arn:aws:logs:us-east-1:ACCOUNT_ID:'
f'log-group:/agentsre/sfn-executions:*'
)
}
}]
},
tracingConfiguration={'enabled': True}
)
return response
The Checkpoint Validator Lambda
python
import boto3
import json
from datetime import datetime, timezone
from agentsre.reasoning_trace import AgentDecisionTrace

cw = boto3.client('cloudwatch', region_name='us-east-1')
dynamodb = boto3.resource('dynamodb', region_name='us-east-1')

def lambda_handler(event: dict, context) -> dict:
"""
Intermediate checkpoint validator.

Validates intermediate workflow output before the next
step consumes it. If validation fails, the replan path
is taken rather than compounding the error forward.

This is the core mechanism for breaking the compound
failure chain described by Lusser's Law.

Called by Step Functions at each checkpoint state.
"""
checkpoint_id = event.get('checkpoint_id')
content = event.get('content', {})
agent_id = event.get('agent_id')
incident_id = event.get('incident_id')
min_confidence = event.get('min_confidence', 0.0)
required_fields = event.get('required_fields', [])

validation_failures = []

# Check 1: Required fields present
for field in required_fields:
if not _deep_get(content, field):
validation_failures.append(
f"Required field missing: {field}"
)

# Check 2: Confidence threshold (if applicable)
if min_confidence > 0:
content_confidence = _extract_confidence(content)
if content_confidence < min_confidence:
validation_failures.append(
f"Confidence {content_confidence:.1%} below "
f"threshold {min_confidence:.1%}"
)

# Check 3: Signal validation consistency (checkpoint B only)
if checkpoint_id == 'B':
signal_validation = event.get('signal_validation', {})
signals_support = signal_validation.get('supports_hypothesis', True)
if not signals_support:
validation_failures.append(
"Signal validation contradicts hypothesis — "
"escalate rather than continue"
)

passed = len(validation_failures) == 0

# Publish checkpoint metric
cw.put_metric_data(
Namespace='AgentSRE/WorkflowCheckpoints',
MetricData=[
{
'MetricName': 'CheckpointPassed',
'Dimensions': [
{'Name': 'AgentId', 'Value': agent_id or 'unknown'},
{'Name': 'CheckpointId', 'Value': checkpoint_id}
],
'Value': 1.0 if passed else 0.0,
'Unit': 'None'
}
]
)

# Store checkpoint result for audit trail
try:
table = dynamodb.Table('WorkflowCheckpointAudit')
table.put_item(Item={
'incident_id': incident_id or 'unknown',
'checkpoint_id': checkpoint_id,
'passed': passed,
'failures': validation_failures,
'checked_at': datetime.now(timezone.utc).isoformat(),
'ttl': int(
(datetime.now(timezone.utc).timestamp()) + 90 * 86400
)
})
except Exception:
pass

return {
'checkpoint_id': checkpoint_id,
'passed': passed,
'failures': validation_failures,
'checked_at': datetime.now(timezone.utc).isoformat()
}

def _deep_get(obj: dict, key: str) -> any:
"""Safely retrieve nested key from dict."""
keys = key.split('.')
for k in keys:
if isinstance(obj, dict):
obj = obj.get(k)
else:
return None
return obj

def _extract_confidence(content: dict) -> float:
"""Extract confidence score from Bedrock response."""
# Try common locations in Bedrock response structure
for path in [
'confidence', 'confidence_score',
'content.0.confidence',
'Body.confidence'
]:
val = _deep_get(content, path)
if isinstance(val, (int, float)):
return float(val)
return 0.5 # Default to uncertain if not found
Workflow-Level SLO Tracking
python
import boto3
import json
from datetime import datetime, timezone
from agentsre.slo_burn import AgentSLOBurnTracker, SLOTarget

cw = boto3.client('cloudwatch', region_name='us-east-1')

def emit_workflow_trace(workflow_execution: dict,
agent_id: str) -> None:
"""
Called by the EmitWorkflowTrace state at workflow completion.
Emits Workflow Reliability Budget metrics to CloudWatch.
This tracks workflow-level success rate — not per-step accuracy.
The number that actually matters for production reliability.
"""
# Count checkpoint events to derive RTD
replan_count = sum(
1 for key in workflow_execution
if key.startswith('checkpoint_') and
not workflow_execution.get(key, {}).get('passed', True)
)

# Determine if workflow completed or escalated
completed = 'execution_result' in workflow_execution
escalated = not completed

# Publish workflow reliability metrics
cw.put_metric_data(
Namespace='AgentSRE/WorkflowReliability',
MetricData=[
{
'MetricName': 'WorkflowCompleted',
'Dimensions': [
{'Name': 'AgentId', 'Value': agent_id}
],
'Value': 1.0 if completed else 0.0,
'Unit': 'None'
},
{
'MetricName': 'WorkflowRTD',
'Dimensions': [
{'Name': 'AgentId', 'Value': agent_id}
],
'Value': float(replan_count),
'Unit': 'Count'
},
{
'MetricName': 'WorkflowEscalated',
'Dimensions': [
{'Name': 'AgentId', 'Value': agent_id}
],
'Value': 1.0 if escalated else 0.0,
'Unit': 'None'
}
]
)

def create_workflow_slo_alarms(agent_id: str,
sns_arn: str,
target_completion_pct: float = 90.0) -> None:
"""
Create CloudWatch alarms for workflow-level SLOs.

Three alarms that matter:
1. Completion rate below target (WRB breached)
2. Workflow RTD above 2 (compounding detected)
3. Escalation rate above 20% (agent outside reliable envelope)
"""
alarm_configs = [
{
'name': f'WorkflowCompletion-SLO-{agent_id}',
'metric': 'WorkflowCompleted',
'threshold': target_completion_pct / 100,
'comparison': 'LessThanThreshold',
'desc': (
f'Workflow completion rate below {target_completion_pct}% '
f'for {agent_id}. '
'Workflow Reliability Budget breached. '
'Review checkpoint failure rates.'
)
},
{
'name': f'WorkflowRTD-High-{agent_id}',
'metric': 'WorkflowRTD',
'threshold': 2.0,
'comparison': 'GreaterThanThreshold',
'desc': (
f'Workflow RTD above 2.0 for {agent_id}. '
'Compounding failure pattern detected. '
'Intermediate outputs failing checkpoints repeatedly.'
)
},
{
'name': f'WorkflowEscalation-High-{agent_id}',
'metric': 'WorkflowEscalated',
'threshold': 0.20,
'comparison': 'GreaterThanThreshold',
'desc': (
f'Workflow escalation rate above 20% for {agent_id}. '
'Agent is outside its reliable operating envelope '
'for this workflow class.'
)
}
]

for cfg in alarm_configs:
cw.put_metric_alarm(
AlarmName=cfg['name'],
AlarmDescription=cfg['desc'],
MetricName=cfg['metric'],
Namespace='AgentSRE/WorkflowReliability',
Dimensions=[
{'Name': 'AgentId', 'Value': agent_id}
],
Period=3600,
EvaluationPeriods=6,
Threshold=cfg['threshold'],
ComparisonOperator=cfg['comparison'],
Statistic='Average',
AlarmActions=[sns_arn],
TreatMissingData='notBreaching'
)
The CloudWatch Insights Queries That Tell You If Compounding Is Happening
# Workflow completion rate trend — your WRB SLI
fields @timestamp, agent_id
| filter Namespace = 'AgentSRE/WorkflowReliability'
| filter MetricName = 'WorkflowCompleted'
| stats avg(Value) as completion_rate by bin(1d), agent_id
| sort @timestamp asc

# Checkpoint failure breakdown — where in the chain is compounding starting?
fields @timestamp, checkpoint_id, passed, failures
| filter ispresent(checkpoint_id)
| stats
sum(case when passed = false then 1 else 0 end) as failures_count,
count() as total_checks,
sum(case when passed = false then 1 else 0 end) / count() * 100 as failure_rate_pct
by checkpoint_id
| sort failure_rate_pct desc

# RTD correlation with completion — are replan events predicting failures?
fields @timestamp, agent_id, WorkflowRTD, WorkflowCompleted
| filter Namespace = 'AgentSRE/WorkflowReliability'
| stats
avg(WorkflowRTD) as avg_rtd,
avg(WorkflowCompleted) as completion_rate
by bin(1d)
| sort @timestamp asc
Run the third query weekly. If avg_rtd and completion_rate are moving in opposite directions — RTD climbing while completion falls — that's your compounding signature. Checkpoint failures are accumulating before they surface as workflow failures.
The Number That Changes Everything
A 95% accuracy per-step rate is a very good scenario in practice. When you look at a workflow with 10 steps, your agentic workflow will fail half the time. At 50 steps, it succeeds only if the coin stays on the edge.
That's not a reason to avoid agentic workflows. It's the design specification for building them reliably. Fewer steps. Checkpoints between steps. Workflow-level SLOs that measure the number that actually matters — not per-step accuracy, but end-to-end completion rate on production workflows over production inputs.
The Step Functions state machine above encodes those design constraints. The CloudWatch alarms enforce them. The agentsre library measures them.
All code is in  agentsre  at github.com/Ajay150313/agentsre. MIT licensed.
Ajay Devineni | AWS Community Builder | Senior SRE/Platform Engineer
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article