[{"data":1,"prerenderedAt":105},["ShallowReactive",2],{"reinvent2026-api316":3},{"id":4,"title":5,"YouTubeChannelID":6,"banner":6,"contributors":7,"description":6,"extension":10,"introBox":11,"meta":14,"pdf":15,"resources":18,"stem":103,"type":6,"video":6,"videos":6,"__hash__":104},"reinvent2026\u002Freinvent2026\u002Fapi316.json","API316: Coding an AI agent from scratch with AWS Lambda durable functions",null,[8,9],"content\u002Fcontributors\u002Frana-kiziltoprak-german.json","content\u002Fcontributors\u002Fserda-kasaci-yildirim.json","json",{"headline":12,"text":13},"Resources for API316: Coding an AI agent from scratch with AWS Lambda durable functions","AI agents need multi-step reasoning, tool execution, human approvals and long-running waits, and they have to keep their state when something fails. In this code talk we built an AI agent, the Expo Booth Scout, as one AWS Lambda durable function: a tool-use loop with Amazon Bedrock, retries with exponential backoff, a human approval gate that costs nothing while it waits, and polling of an external system.\u003Cbr>\u003Cbr>This page has the slides, the demo code, and documentation for each part of the talk.",{},{"source":16,"headline":17},"https:\u002F\u002Fserverlessland.s3.us-east-1.amazonaws.com\u002Fpdf\u002Freinvent2026\u002Fapi316.pdf","Slides from the presentation",{"left":19,"right":69},[20,37,51,58],{"headline":21,"subheading":22,"text":23,"bullets":24},"AWS Lambda durable functions","The mental model","Durable functions checkpoint each operation and replay your code after an interruption, so completed work is not run again and waits cost no compute.",[25,28,31,34],{"text":26,"link":27},"Lambda durable functions developer guide","https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Fdurable-functions.html",{"text":29,"link":30},"Basic concepts","https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Fdurable-basic-concepts.html",{"text":32,"link":33},"Key concepts: checkpoint and replay","https:\u002F\u002Fdocs.aws.amazon.com\u002Fdurable-execution\u002Fgetting-started\u002Fkey-concepts\u002F",{"text":35,"link":36},"Durable Execution SDK for Python","https:\u002F\u002Fdocs.aws.amazon.com\u002Fdurable-functions\u002Fsdk-reference\u002Flanguages\u002Fpython\u002F",{"headline":38,"subheading":39,"text":40,"bullets":41},"The tool-use loop","Checkpointed model turns and tool calls","Each model turn and each tool call runs in \u003Ccode>context.step()\u003C\u002Fcode>, so after an interruption the agent resumes at the first unfinished step without calling the model again.",[42,45,48],{"text":43,"link":44},"Steps","https:\u002F\u002Fdocs.aws.amazon.com\u002Fdurable-execution\u002Fsdk-reference\u002Foperations\u002Fstep\u002F",{"text":46,"link":47},"Serialization of step results","https:\u002F\u002Fdocs.aws.amazon.com\u002Fdurable-execution\u002Fsdk-reference\u002Fstate\u002Fserialization\u002F",{"text":49,"link":50},"Tool use with the Amazon Bedrock Converse API","https:\u002F\u002Fdocs.aws.amazon.com\u002Fbedrock\u002Flatest\u002Fuserguide\u002Ftool-use.html",{"headline":52,"subheading":53,"text":54,"button":55},"Retries with exponential backoff","Recovering from transient failures","A retry strategy on \u003Ccode>StepConfig\u003C\u002Fcode> retries a failed tool step with backoff, instead of failing the whole agent.",{"text":56,"link":57},"Docs","https:\u002F\u002Fdocs.aws.amazon.com\u002Fdurable-execution\u002Fsdk-reference\u002Ferror-handling\u002Fretries\u002F",{"headline":59,"subheading":60,"text":61,"bullets":62},"Serverlesspresso","Workshop","Serverlesspresso is an event-driven coffee-ordering application. The workshop builds it with AWS Lambda durable functions.",[63,66],{"text":64,"link":65},"Serverlesspresso workshop: the AWS Lambda durable functions edition","https:\u002F\u002Fcatalog.us-east-1.prod.workshops.aws\u002Fworkshops\u002Fa6b114eb-4e0a-4d3e-8202-be75589428fe\u002Fen-US",{"text":67,"link":68},"Learn more about Serverlesspresso","https:\u002F\u002Fserverlessland.com\u002Fexplore\u002Fserverlesspresso",[70,76,82,89],{"headline":71,"subheading":72,"text":73,"button":74},"Human approval","Suspend until the attendee decides","The \u003Ccode>request_approval\u003C\u002Fcode> tool uses \u003Ccode>context.wait_for_callback()\u003C\u002Fcode>. The agent suspends with no Lambda running until the approve or reject decision arrives.",{"text":56,"link":75},"https:\u002F\u002Fdocs.aws.amazon.com\u002Fdurable-execution\u002Fsdk-reference\u002Foperations\u002Fcallback\u002F",{"headline":77,"subheading":78,"text":79,"button":80},"Polling an external system","Reserve the swag","The \u003Ccode>reserve_swags\u003C\u002Fcode> tool submits reservations to an asynchronous service, then uses \u003Ccode>context.wait_for_condition()\u003C\u002Fcode> to poll until every reservation is confirmed. The function suspends between polls.",{"text":56,"link":81},"https:\u002F\u002Fdocs.aws.amazon.com\u002Fdurable-execution\u002Fsdk-reference\u002Foperations\u002Fwait-for-condition\u002F",{"headline":83,"subheading":84,"text":85,"button":86},"Demo code repository","GitHub repo","The Expo Booth Scout agent, its web UI and the AWS SAM template, ready to deploy in your own account.",{"text":87,"link":88},"Code","https:\u002F\u002Fgithub.com\u002Faws-samples\u002Fsample-reinvent2026-api316-Coding-an-AI-agent-from-scratch-with-AWS-Lambda-durable-functions",{"headline":90,"subheading":91,"text":92,"bullets":93},"Keep learning","Workshops and more serverless","Hands-on workshops, the new Lambda form factors, and more serverless content.",[94,97,100],{"text":95,"link":96},"Serverless workshops","https:\u002F\u002Fs12d.com\u002Fsvs-workshops-codetalk",{"text":98,"link":99},"Reimagine AWS Lambda","https:\u002F\u002Fs12d.com\u002Freimagine-lambda",{"text":101,"link":102},"Serverless Land","https:\u002F\u002Fserverlessland.com","reinvent2026\u002Fapi316","FwLtsmoTY79yo2kMkDB2L6NGg4Rr9bVdsLqMbQrCFkU",1795477307864]