Tracking State Across Steps

agent state and a bounded scratchpad

Part of: Multi-Step Task Agent

The results dict from the last lesson does more than feed argument substitution. It is the agent's state : everything the agent has learned so far. This lesson gives that state a shape and, just as importantly, stops it from growing without bound. Two flavors of agent, one state problem A fixed-plan agent , the kind this lesson builds, plans once and then executes, reaching back into results only to resolve arguments. A replanning agent is looser: after each step it hands the model a summary of what has happened and asks, "given this, what's the next step?" That second style needs a real summary of state to send back in: Replanning adapts to surprises like a search coming back empty or a number that makes no sense, but it spends a planning call on every step instead of one call up front. The fixed plan is cheaper and more rigid; replanning is adaptive and pricier. Pick per task. State grows exactly like chat history This is the same problem a chatbot's message history has. Every step you log grows the record, and eventually the record is too big to resend usefully, whether a human is reading a trace or a model is reading a summary. The fix is the same too: keep it bounded. Keep the

Challenge: Compress the Step Log