
When an agent drifts off course mid-task, the context window is usually the culprit. This guide covers practical memory management: what belongs in the system prompt, what belongs in files, when to clear context — and three techniques for long tasks that don't derail.













