When a project is getting bigger and you need to clean the context the agent is not aware enough of the structure and starts making mistakes. (this is my experience, might be another cause)
It would be a great idea if the agent would keep a Meta Context that views the app that is being build from a birds eye view. Just knowing how all parts interact and where different functions have their place in the app.
When cleaning up, this meta context would be read and the agent but be much more aware of the complete overview of the app.
And, showing this to a user visually, could improve their prompts to the agent which increases their success rate when building. This leads to happy customers and more customers.