Exercise 2: Two Agents, One Working Directory — Possible Solution ==================================================================== THE SPECIFIC RISK ------------------------------ Per this chapter, running two agents in parallel inside the same working directory means "both are reading and writing the same files on disk." Concretely: "one agent's edit can silently overwrite the other's, or one agent can read a half-finished intermediate state left by the other." Because both agents share the exact same files, there is no structural barrier preventing one agent's changes from clobbering or corrupting the other's in-progress work. WHY THIS ISN'T A HYPOTHETICAL EDGE CASE ------------------------------ Per this chapter, this is described as the DEFAULT outcome - "the default, if nothing explicit is done about it" - meaning parallel agents collide on files unless something is deliberately set up to prevent it, not merely as an unlucky rare occurrence. HOW A WORKTREE FIXES IT ------------------------------ Per this chapter, a worktree gives each agent "its own files on disk" in a separate directory, all linked to the same underlying git repository and sharing the same commit history. Since each agent's file edits now live in a genuinely different folder, one agent's changes cannot overwrite or interfere with the other's - the chapter's own git worktree add example shows creating a second working directory precisely so that "its file edits cannot collide with anything happening in the original folder." WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly names the file-collision/overwrite risk this chapter describes, correctly notes that this is the default behavior absent any fix, and correctly explains that a worktree solves it by giving each agent a separate directory rather than a separate permission or setting.