I think building new code up to a functional, code and security standard will get easier and easier with AI and we may reach a point where the list of bugs is shorter.
However, based on what I have seen building my software factory (7 agents, each with their own roles) and iterating on it, an agent will only have a certain amount of context and scrutiny it can dedicate. So I found that segregation of resonsibilities between agents (which one does which checks) + automated checks and tests are really important. However, I don't know yet to what extent. It feels like my factory is getting better and better, but there are still things being sent back, and still there is an occasional helper that is getting re-written a bit differently (even if I have a tech lead agent who is looking at the whole code).
So I can only imagine the complexity for a legacy app or a huge app where even multiple agents cannot have enough context to write code that considers code and functions next to the feature it is working on.
I don't think that agents at this time can have the capability of a senior dev who really knows the system. The best thing we can do is to distill how a senior dev looks at the system from all different angles and write instructions as clear and short as possible. Then iterate and test continuously with measuring the outcomes. At least that's what I'm trying to do.