The Wrong Question
In 2025, data from Golabs showed that 76% of enterprise AI use cases were bought — purchased as ready-made software — rather than built in-house from scratch. Yet across the industry, engineering teams keep spending years rebuilding infrastructure that vendors already sell as a managed service: software the vendor runs and maintains for you, accessible through a subscription or API rather than something you host yourself. They are building the wrong parts of the system.
The question "should we build or buy our AI application?" is a trap, because it treats the decision as one single choice when it's really a stack of at least five distinct technologies layered on top of each other. The right answer for one layer is almost always the wrong answer for another.
Every company using AI today is, whether they realize it or not, already mixing build and buy. No one builds their own foundation model — the giant language model that does the actual reasoning and text generation — from scratch; they call it through an API, a defined way for one piece of software to request services from another. No one builds their own data centers; they rent cloud servers. So the real decision was never "build everything" versus "buy everything." It's a layer-by-layer judgment call: where does your team's expertise create a genuine edge over competitors, and where would you be better off moving faster with an off-the-shelf solution?
Getting this judgment wrong has real costs. Pick the wrong vendor for a layer that needed custom control, and you get locked into a system that doesn't fit your needs. Misjudge it further, and the whole project can collapse — Gartner forecasts that more than 40% of "agentic" AI initiatives (AI systems designed to autonomously plan and carry out multi-step tasks) will be canceled by the end of 2027. This guide lays out a framework for making that judgment layer by layer, rather than all at once.

The Modern AI Agent Stack: A Five-Layer Decision
Thinking of an AI agent as a single entity is the first mistake. It's a system of interconnected components, each with its own build-vs-buy economics. An analysis from AugmentCode proposes a five-layer model that offers a clear way to break down the decision. Almost no one builds everything; the crucial choice is deciding which layers you own.
Layer 1: The Foundation Model
This is the large language model (LLM) itself—the engine that provides reasoning, language understanding, and generation. The options are typically commercial APIs from providers like OpenAI, Anthropic, and Google, or open-source models hosted on cloud infrastructure.
Verdict: Almost always buy. Building a competitive foundation model from the ground up is a nine-to-ten-figure research project requiring specialized talent and massive computational resources. Even fine-tuning an existing model, while more accessible, is a non-trivial undertaking. For the vast majority of applications, the performance, scalability, and continuous improvement offered by leading model providers through an API are the only practical choice. The decision here is which provider to buy from, not whether to build the model yourself.
Layer 2: Orchestration
The orchestrator is the brain of the operation. It manages the agent's workflow: decomposing a complex task into smaller steps, routing requests between different tools or sub-agents, managing state, and handling retries and errors. This is where the agent's reasoning process is defined.
Verdict: Hybrid. Use an open-source framework and write custom configuration. This layer is a battleground. Full-service vendor platforms offer pre-built orchestration logic that can get you to a prototype quickly. However, their abstractions can become restrictive as your agent's complexity grows.
The most common and effective approach is to adopt a powerful open-source framework and write the orchestration logic as code or configuration. This gives you the control to implement custom reasoning paths and complex tool-calling sequences without having to build the underlying state management and execution engine from scratch. You own the logic, not the plumbing.
Layer 3: Tool Integrations
Agents are only useful if they can interact with the outside world. Tools are the connectors that allow the LLM to read files, search a database, call an external API, or query a knowledge base. This is the agent's sensory and motor system.
Verdict: Hybrid. Buy standard connectors, build proprietary ones. If you need to connect to a common SaaS tool like Salesforce or a standard database like Postgres, there is almost certainly a pre-built, managed connector you can buy or find in an open-source library. Building these yourself provides no competitive advantage.
However, if your agent needs to interact with a proprietary internal system, a legacy database, or a unique API, you will have to build that integration yourself. This is focused, high-value work that directly enables the agent to perform its core function within your specific business context.
Layer 4: Domain Logic
This is your secret sauce. Domain logic includes the specific business rules, compliance checks, proprietary algorithms, and decision-making criteria that differentiate your service from a competitor's. It's the logic that dictates how a task should be done, not just that it can be done.
Verdict: Always build. According to AugmentCode, this is the only layer where building is consistently the right answer. Your domain logic is your intellectual property. It cannot be replicated by a competitor who simply subscribes to the same vendor. This is where your engineering resources should be concentrated, as it's the source of durable competitive advantage. Outsourcing this layer is equivalent to outsourcing your core business.
Layer 5: Observability and Evaluation
How do you know if your agent is working? How do you diagnose failures? How do you prove a new version is better than the last? The observability and evaluation layer provides the infrastructure for logging, tracing, testing, and monitoring your application.
Verdict: Almost always buy. As we'll see in the next section, the scope of a production-grade evaluation system is enormous. While it's tempting to start with a simple script that runs a few prompts, this approach doesn't scale and leaves you blind to regressions. Commercial platforms for LLM evaluation and observability are a mature category. They provide dashboards, tracing, automated scoring, and test case management out of the box, saving you months of engineering effort. The key is to choose a platform that integrates with your stack rather than locking you into a specific orchestration paradigm.
A Worked Example: The True Cost of Building an Evaluation Layer
The advice to "buy" the evaluation layer often meets resistance. It feels like a core competency. "How hard can it be?" teams ask. "We'll just write some Python scripts."
This thinking dramatically underestimates the scope. Let's use the detailed breakdown for a voice AI evaluation system from Coval, a provider in the space, to illustrate what building "just" this one layer actually entails. While their focus is voice, the components are nearly identical for any complex agent.
The Scope of "Just" an Evaluation System
A robust evaluation infrastructure isn't one thing; Coval identifies at least five distinct sub-systems you'd need to build:
Observability: You need a pipeline to log every conversation, capture turn-by-turn metrics (like latency and token counts), track business outcomes, and store this data for historical analysis. This requires real-time dashboards and an alerting system.
Agent Evaluation: You need to systematically measure quality. This means infrastructure for automated scoring against a rubric, measuring task completion rates, assessing response accuracy and relevance, and tracking these quality metrics over time to spot trends.
Testing: You need to validate changes before they hit production. This requires a simulation engine to run test cases, automation for regression testing, tools for generating adversarial or edge-case tests, and a system to aggregate and report on results.
Debugging: When a test fails or a user reports an issue, you need tools to find the root cause. This includes a way to replay conversations, analyze each turn, attribute the failure to a specific component (the LLM, a tool call, the retriever), and detect common failure patterns across many conversations.
Continuous Improvement: You need to close the loop. This means building a pipeline to turn interesting production conversations into new test cases, infrastructure for A/B testing different models or prompts, and tools for comparing quality across versions.
The Price Tag in Engineering-Months
Building this is a major project. Coval estimates that creating this infrastructure from scratch takes 6 to 12 months with a dedicated team of 3 to 5 engineers (a mix of backend and frontend).
Let's translate that into cost. A conservative estimate for a 4-person team (2 backend, 1 frontend, 1 QA/DevOps) for 9 months is 3 person-years of senior engineering effort. The fully-loaded cost of that effort can easily exceed a million dollars, even before you've shipped version 1.0 of your actual product.
The Hidden Maintenance Tax
The costs don't stop at launch. A report from Golabs on enterprise AI agents estimates that annual maintenance for these systems—whether custom-built or heavily customized—runs between 15% and 30% of the original build cost.
That evaluation suite you just spent a million dollars and 9 months building now requires an additional $150,000 to $300,000 per year in engineering time just to keep the lights on. It needs to be updated as your agent's architecture changes, scaled as usage grows, and adapted to new evaluation techniques. It becomes a product in its own right, with its own backlog and resource demands, pulling focus from your core application.
This is the true cost of building a layer that is not your core business. You are not just building a feature; you are committing to maintaining a complex internal software product for its entire lifecycle.
The Trade-Offs You're Actually Making
The layer-by-layer framework helps quantify the cost, but the decision also involves qualitative trade-offs between speed, control, and focus.
Speed vs. Control: The Platform Lock-in Dilemma
Buying a managed platform for orchestration or retrieval is undeniably fast. You get a working system in days, not months. The trade-off is control. The platform's abstractions—how it defines a "tool," how it manages state, how it structures a RAG pipeline—become your abstractions.
If your needs evolve beyond what the platform was designed for, you face a painful choice: compromise your application's design or undertake a costly migration to a more flexible system. The switching cost for a deeply embedded orchestration or retrieval layer is immense. It's not just about changing API calls; it's about re-architecting your agent's core logic.
This is why the hybrid approach for orchestration (using an open-source framework you host yourself) is so powerful. You get the speed of a pre-built engine but retain full control over the logic you build on top of it, minimizing lock-in.
Cost vs. Insight: When to Own the Ledger
For most companies, buying infrastructure is a straightforward cost-benefit analysis. But for businesses whose unit economics are tightly coupled to AI costs—for example, a service that charges per query—the "black box" nature of a managed platform can be a liability.
When you buy a managed retrieval service, you pay a single price per query or per document. You lose visibility into the underlying costs of compute, storage, and token consumption. If you need to drive down your cost-per-query by 10%, you are reliant on the vendor's features and pricing tiers.
By building (or, more accurately, assembling) your own retrieval stack from open-source components like pgvector on cloud infrastructure, you own the entire cost ledger. You can see exactly where the money is going, with direct access to the levers that control it—choosing a cheaper embedding model, tweaking indexing strategies, or optimizing instance sizes. This level of control is a strategic necessity for some business models. It mirrors the strategic thinking outlined by researchers at the National University of Singapore for governments, who may choose to build "sovereign" capabilities for critical functions to ensure control, even if commercial options exist.
Focus vs. Breadth: Where Your Engineers Create Value
Your engineering team has a finite capacity. Every hour they spend building an evaluation dashboard is an hour they don't spend improving your agent's proprietary reasoning process.
The initial build cost of an AI agent is often just 25-35% of its total cost of ownership over three years, according to Golabs. The rest is infrastructure, operations, and that relentless 15-30% annual maintenance tax.
The strategic goal is to focus your scarce, expensive build-and-maintain budget on the one layer that produces a return: your domain logic. For everything else, the goal should be to get the most capability for the lowest total cost of ownership. More often than not, that means buying a specialized solution or leveraging a mature open-source project, not starting a new internal infrastructure project. An evaluation framework's primary job, as noted by DeepEval, is to enable faster, more confident development by shortening feedback loops before deployment. Buying one directly serves that goal.
The Right Question to Ask
The "build vs. buy" debate for AI applications is over. The honest answer is "both." The useful question is "which parts?"
So stop asking whether you should build your AI agent. Instead, map your architecture onto the five layers described above and make a deliberate call for each one. A few concrete questions can anchor that discussion:
Which layers are our competitive advantage? For almost every company, the honest answer is just the domain logic — the business rules and judgment calls a competitor can't copy simply by signing up for the same vendor.
For all other layers, what is the fastest, most scalable, and most cost-effective way to acquire this capability?
What is the three-year total cost of ownership for building this component ourselves, including that 15-30% annual maintenance tax?
What control are we giving up by buying, and what would it cost us to switch vendors later if we chose wrong?
Answering these questions honestly, layer by layer, is what separates a deliberate strategy from a guess. It's how you avoid both the 76% mistake — buying something you should have built — and its mirror image: sinking a team of engineers for a year into rebuilding a dashboard a vendor already sells for a subscription fee. Do this well, and your scarcest resource — the engineers who understand your business — ends up spending their time on the one layer where that understanding actually pays off, while the market handles the rest.

