| Looking at the prompts op has shared, I'd recommend more aggressively managing/trimming the context. In general you don't give the agent a new task without /clearing the context before. This will enable the agent to be more focused on the new task, and decrease its bias (if eg. reviewing changes it has made previously). The overall approach I now have for medium sized task is roughly: - Ask the agent to research a particular area of the codebase that is relevant to the task at hand, listing all relevant/important files, functions, and putting all of this in a "research.md" markdown file. - Clear the context window - Ask the agent to put together a project plan, informed by the previously generated markdown file. Store that project plan in a new "project.md" markdown file. Depending on complexity I'll generally do multiple revs of this. - Clear the context window - Ask the agent to create a step by step implementation plan, leveraging the previously generated research & project files, put that in a plan.md file. - Clear the context window - While there are unfinished steps in plan.md: -- While the current step needs more work --- Ask the agent to work on the current step --- Clear the context window --- Ask the agent to review the changes --- Clear the context window -- Ask the agent to update the plan with their changes and make a commit -- Clear the context window I also recommend to have specialized sub agents for each of those phases (research, architecture, planning, implementation, review). Less so in terms of telling the agent what to do, but as a way to add guardrails and structure to the way they synthesize/serialize back to markdown. |
I actually think it works better that way, the agent doesn't have to spend as much time rereading code it had previously just read. I do have several "agents" like you mention, but I just use them one by one in the same chat so they share context. They all write to markdown in case I do want to start fresh if things do go the wrong direction, but that doesn't happen very often.