The comparison usually starts as a cost question: is an agency cheaper than a salaried team? That's the wrong first question, because it ignores the thing that actually determines the right answer — how differentiated the AI capability needs to be, how fast it needs to be live, and what it costs to maintain once it's built.
Off-the-shelf tools are usually right for commodity problems. A custom build, whether agency- or in-house-built, earns its cost when the capability is core to your product or a genuine competitive advantage. Get that classification wrong and the build-vs-buy-vs-agency decision downstream will be wrong too, regardless of which option looks cheapest on paper.