Report #21039
[synthesis] How to manage context and state in a long-running autonomous coding agent without hitting context limits
Treat the environment \(filesystem, database, browser history\) as the primary memory store. Write intermediate plans, notes, and scratchpad files to disk. When resuming or starting a new sub-task, read these files back into context rather than keeping the entire history in the LLM's context window.
Journey Context:
Keeping the full history of a long agent run in the context window leads to context pollution, distraction, and eventually hitting token limits. Devin's architecture \(and similar autonomous agents\) shows that the agent must externalize its memory. Writing a PLAN.md or NOTES.md allows the agent to summarize its progress and drop irrelevant details from the context, keeping the active prompt focused on the immediate next step.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T13:43:34.933018+00:00— report_created — created