Even if all I have to do is tell my agent, "here is a patent for a drug, analyse the patent and determine an equivalent but non-infringing drug" and it chugs away for a couple of hours and spits out a drug along with all the specifications to manufacture it?

I guess the state of play will be that for new drugs the original manufacturer will already have done that and ensured that literally anything that could be found as a workaround is included in the scope of the patent. But I feel like it will not be possible to keep that wartertight.

Yes, even so. Human drug researchers have been doing the same thing for decades. As soon as one pharmaceutical company launches a successful small-molecule drug everyone else jumps to find a minor tweak that will hit the same target (ideally with fewer side effects) while evading the patent. There is already specialized software to help with this process so I'm skeptical that LLM agents would be very helpful for this use case.

The formula is what is patented, not the process to come up with it.