The way I've done it has been when there's a longer task, I give it a markdown document that has a plan with numbered steps, and then for each step start a fresh context window and tell it to update that doc as it goes with any decisions taken or deviations from the plan, or other context needed for future steps. If it gets close to the end of the context I tell it to summarize the current state and anything a fresh context would need to know.