Skip to content

#worktrees

Public posts with this tag · RSS

Follow #worktrees

Long-running coding agents: when to stop and split. The pattern I keep seeing: an agent starts strong, then drifts after a few hundred steps—context window bloats, earlier decisions get forgotten, and it starts re-litigating things it already solved. The fix isn't a bigger context window, it's knowing when to checkpoint and fork into a fresh session with a tight summary instead of the full history. Rule of thumb I use: if the agent's last 10 actions include more than 2 corrections of its own prior work, stop and split. Write a short handoff doc (goal, decisions made, open issues) and start clean. Cheaper and more reliable than letting it spiral. https://compositecode.blog/2026/11/03/keeping-long-running-agents-on-track/

Yesterday I wrote up a piece on AI agent collisions with worktrees. Digging into why isolating agents in separate git worktrees doesn't fully solve the coordination problem once you've got multiple agents touching shared state, ports, databases, or build artifacts. Worktrees help with file-level isolation, but they don't stop two agents from racing on the same dev server, migration, or external resource. It's available here: https://compositecode.blog/2026/11/02/agent-collisions-beyond-worktrees/

I've written about setting up and using worktrees before, but problems still persist, If you're aggressively getting things built - running multiple agents in parallel across branches - collisions end up happening a lot: lockfile clobbering, two agents editing the same shared module from different worktrees, stale state bleeding across sessions, merge conflicts that nobody actually caused by hand. In this post I've written up a few ideas on how to resolve - or possibly prevent some of those conflicts: tighter scoping per agent, better signaling before writes, some guardrails around shared files, and a few patterns for catching collisions early instead of after they've already compounded. Anyway, blagh blagh blagh, here's the post. Give it a read. Got other ideas? I've a got a few more that are hardcore solutions, and solutions that are in between full on additional machines and accounts and worktrees. https://compositecode.blog/2026/11/02/agent-collisions-beyond-worktrees/

Giving Every Agent Its Own Branch: Git Worktrees for Parallel AI Work To note, I've written this post and at this time... it's kind of a *halfway* solution and really only fixes part of the problems of multiple agents running on a singular machine workspace. Give it a read and I'll have some suggested solutions coming your way real soon. https://compositecode.blog/2026/08/19/worktrees/

You’re all caught up.