Track state and progress
Keep a compact record of goals, completed work, and the next useful step.
- Design state that helps a loop resume without repeating or losing work.
A multi-step loop needs state: the user’s goal, relevant constraints, completed actions, important results, and outstanding work. Keep this state explicit and bounded. Store durable results outside a short model context when they must survive interruptions. Separate trusted application state from untrusted text returned by tools or documents.
A small example
state = {"goal": "prepare report", "completed": ["collect totals"], "next": "check outliers"}
print("Next:", state["next"])Next: check outliers
A progress summary helps prevent repeated work and supports recovery after a timeout. Persist only what is necessary, protect sensitive fields, and version stored state when its structure changes. The model can propose a state update; application code should validate it before saving.
Key takeaways
Design state that helps a loop resume without repeating or losing work.
Bound the loop, validate actions, and make its outcome observable.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…