Tried the usual approaches - longer context windows, better prompts, chat history - but none of it worked reliably. The fundamental issue is that LLM agents are stateless by nature.
So I built a state machine that persists everything to DynamoDB: - Which development phase we're in (requirements → frontend → backend → etc) - Granular todos within each phase - What's been completed vs what's pending - Sandbox state (E2B sandboxes can die/restart) - S3 code sync status
Now when something goes wrong (and it always does), the agent just resumes from the exact todo it was working on. No context loss, no duplicate work.