Not heard of it before but it sounds like the author massively overestimated resource requirements there. Trantor is supposed to have 800+ districts, with an average population of 50m each, so that's a total population of over 40 billion. There's absolutely no way that would require 20+ planets dedicated to agriculture to feed it unless either they're all tiny planets or morbidly obese people!
Earth currently has a population of 7.9 billion, and can support itself food wise. Could surely support a higher population is food was better shared, despite starvation and shortages in some places there is a lot of excess food in others. But let's just say it supports 8 billion for now.
Roughly 50% of Earth's habitable land is used for agriculture. We could definitely make more efficient use of that land and you'd also expect an "agricultural world" to use more land for agriculture than Earth, so given both of those lets say you could produce 30% more than Earth. So one Earth sized planet could support a population of 10.4 billion (and I think that's a VERY conservative estimate).
So you should be able to provide food for a planet like Trantor with just 4 Earth sized agricultural worlds. No need for 20+
Rant aside, ecumenopoli do already provide energy via trade though. Plus not long after you start to get them up and running energy becomes ridiculously abundant anyway, so it's not really needed. Underground districts would be nice though. I once had the subterranian empire event on a planet, got an extra 9 max districts from that, converted it into an ecumenopolis thinking it would be a huge one and last the bonus districts