6 views
This guide focuses on Step Functions agents for production systems, with practical trade-offs for reliability, security, and cost.
A while loop in Lambda that calls Bedrock until “done” is a token incinerator without audit. Step Functions give you timeouts, maps, human approval via task tokens, and compensations finance will accept. Day 33 replaces infinite ReAct with an explicit graph.
⚡ TL;DR: Model turns as states: plan → toolChoice → tool/approve → evaluate → succeed|compensate. Cap iterations and token budget in state. Use Standard workflows for human-in-the-loop, Express for short chats.
Step Functions agents: production guidance
text
Start → Plan → ToolChoice →
Choice:
needs_approval → WaitForTaskToken
safe_tool → InvokeTool → Evaluate →
(continue | succeed | fail_compensate)
python
for i in range(100):
out = converse(...)
if not out.tool_calls: break
run_tools(out.tool_calls)
Human approval with task tokens
json
Approval posts to Slack/Jira; Approve calls {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke.waitForTaskToken",
"Parameters": {
"FunctionName": "requestApproval",
"Payload": {
"taskToken.$": "$$.Task.Token",
"diff.$": "$.proposedPatch",
"sessionId.$": "$.sessionId"
}
},
"TimeoutSeconds": 86400,
"HeartbeatSeconds": 3600
}
SendTaskSuccess. Heartbeats detect abandoned approvals.
Compensations and budgets
Ifcreate_resources succeeds and register_dns fails, a compensating state deletes resources. Track tokens_used and iteration in state; fail closed when budgets exceed — do not rely on the model to stop.
Production checklist
- [ ] Max iteration + token budget in state
- [ ] waitForTaskToken for mutating actions
- [ ] Compensating transitions on failure paths
- [ ] Execution history retained for replay
- [ ] Alarms on failure rate and stuck approvals
- [ ] Game-day: force compensate path once per quarter
Series navigation
← Day 32 · Day 34 → Last updated September 11, 2026 Related: Day 76: p99 of Agents: Queueing, Not Just Model Latency; Day 82: Voice and Realtime Agents; Day 56: Supervisor Patterns on Bedrock Agents.Watch: 100 Days of AI on YouTube
Short videos from CheatCoders, one AI engineering topic per day.
Most viewed
- Python Decorators Explained: From Simple Wrappers to Production Patterns
- Claude Code vs Cursor vs GitHub Copilot: Choose by Workflow, and Set Up One Repo That Works With All Three
- AI Agent Frameworks in 2025: LangGraph vs CrewAI vs AutoGen vs Raw API
- Python String Methods: Every str Method With Real Production Examples
- Css Animation Performance: Performance-Optimized Motion for Modern UIs
Newly added
- AWS Systems Manager Parameter Store: Hierarchical Runtime Config for Coding Agents
- Amazon Cognito Identity Pools: Federate Coding-Agent Tool Callers Without Long-Lived Keys
- Amazon Athena for Coding Agents: Query Tool Audit Logs and Eval Traces on S3 Without a Warehouse
- AWS Batch for Coding Agents: Parallel Overnight PR Reviews and Long-Running Jobs Without Lambda Timeouts
- Amazon Bedrock Prompt Management: Version and A/B Test Coding-Agent System Prompts
Deep-dive PDF
Get the expanded guide for this post — extra diagrams-style checklists, failure modes, and a production walkthrough. Free when you subscribe to CheatCoders.
Already subscribed? or open the subscribe page.
Discover more from CheatCoders
Subscribe to get the latest posts sent to your email.
