Skip to main content
المدونة

Zalt Blog

Deep Dives into Code & Architecture

AT SCALE

Build vs Buy an AI Agent: When a Custom Agent Is Worth It

By محمود الزلط
Insights
12m read
<

Most teams asking 'should we build a custom AI agent?' already have their answer: no. Here is a concrete 5-question framework that tells you exactly when a custom build is worth it and when you are just burning time and budget.

/>
Build vs Buy an AI Agent: When a Custom Agent Is Worth It - Featured blog post image
Mahmoud Zalt

1:1 Mentor

Are you a software engineer moving into AI?

Let's have a call. I'll help you modernize your skills and learn the tools, systems, and architecture behind real AI products. One session or ongoing.

Hire AI Employees

Hire AI Employees that work 24/7. No code.

Build vs Buy an AI Agent: The Short Answer

Start with an off-the-shelf platform. Build a custom AI agent only when you have identified a specific, defensible reason why no existing platform can meet a hard constraint or create a real competitive moat. Most teams that come to me convinced they need a custom build actually need a better-configured platform, not a bespoke system.

I am Mahmoud Zalt, an independent senior AI systems architect with 16+ years building production software since 2010. I founded Sista AI, and for the past year its autonomous agents have earned their keep in production, which is the only place build-versus-buy stops being theoretical. I work solo, not as an agency, which means I have no incentive to sell you a complex build when a simpler solution fits. If you are evaluating whether to build a custom AI agent for your product or workflow, my AI Agent Development service is where we start with exactly this decision.

The Buy-to-Build Spectrum

The market is not binary. There are four tiers, and buyers routinely skip the middle two:

TierWhat you getExamplesWhen to stop here
1. No-code SaaS agentFully hosted, GUI config, pre-built integrationsIntercom Fin, Drift, Salesforce EinsteinYour use case is a known category (support, sales outreach, scheduling)
2. Low-code orchestration platformVisual workflow builder, LLM routing, tool connectorsZapier AI, Make, Voiceflow, BotpressYou need custom logic but your team has no ML/backend depth
3. SDK / framework layerCode-first but on a maintained runtimeLangChain, LlamaIndex, Vercel AI SDK, CrewAIYou need flexibility without owning infra or the agent loop
4. Full custom buildYou own the agent loop, memory, tool-calling, evals, observabilityIn-house using Anthropic/OpenAI SDKs directly, custom MCP serversA genuine constraint or moat exists (see below)

Most buyer mistakes happen by jumping from Tier 1 straight to Tier 4 after a single failed demo, or by treating Tier 3 frameworks as 'custom enough' when a Tier 2 platform would have shipped in a third of the time.

When to Buy (Most of the Time)

Buy or stay on a platform when all of the following are true:

  • The use case is a known category. Customer support, meeting summarization, lead qualification, internal Q&A over docs. These are solved problems. A platform ships faster and someone else handles model updates, rate limiting, and compliance certifications.
  • Your team will not maintain AI infrastructure. Custom agents need evals, prompt versioning, retrieval pipelines, and observability. If you have no one to own that, you will accumulate silent drift: the agent degrades and nobody notices until a customer complains.
  • Time-to-value is the constraint. A Tier 1 or Tier 2 solution can be live in days. A proper custom build, done correctly with evals and guardrails, takes 6 to 12 weeks minimum for anything non-trivial.
  • The workflow fits the platform's data model. If you are not fighting the platform's assumptions about state, memory, or tool-calling, stay on it.

A concrete example: a 40-person SaaS company asked me to 'build them a custom support agent.' After a single discovery session it was clear their ticket taxonomy was standard, their integrations were Zendesk and Slack, and their team had no ML background. I configured Intercom Fin with a custom knowledge base, added a human-in-the-loop escalation rule for refund requests over a threshold, and they were live in two weeks. No custom code shipped. That is the right call.

When to Build Custom (The Real Criteria)

Build a custom AI agent when at least one of these hard criteria is met, not just when a platform feels limiting:

1. The agent loop itself is the product

If the intelligence, routing, or reasoning of the agent is what you are selling, you cannot outsource the loop to a third party. An AI-native startup building autonomous code review, contract analysis, or drug interaction screening needs to own its own agent architecture. Delegating that to a platform means your competitor can replicate your product in a weekend by subscribing to the same service.

2. Hard data residency or security constraints

Regulated industries (healthcare, finance, defence) often prohibit sending data to a third-party LLM endpoint at all. If you cannot pass patient records or trading data through a vendor's hosted pipeline, you need a custom build against a self-hosted or enterprise-contracted model. This is a compliance constraint, not a preference.

3. Deep proprietary data integration

Platforms handle generic RAG over uploaded PDFs. They do not handle real-time joins against your internal graph database, multi-hop retrieval across 15 internal APIs, or tool-calling against systems that require custom authentication flows. When retrieval complexity exceeds what a platform's connector model supports, you hit a ceiling fast.

4. Latency or throughput that a hosted platform cannot guarantee

If your agent is in a synchronous user-facing loop and you need p95 latency under 800ms, you cannot accept a shared-tenant platform's variable performance. You need to control the model endpoint, the streaming strategy, and the caching layer.

5. Multi-agent orchestration with non-standard coordination patterns

Platforms support linear chains and simple branching. If you need a supervisor agent dynamically spawning specialist sub-agents, parallel execution with result merging, or shared memory across a fleet of agents, you are past what most orchestration GUIs can express reliably.

The 5-Question Decision Framework

Run through these in order. Stop as soon as you hit a 'buy' answer.

  1. Does a named platform already do 80%+ of this in production for similar companies? If yes: start there, configure it aggressively, identify the 20% gap before assuming it cannot be bridged.
  2. Is the data path legally or contractually prohibited from leaving your infrastructure? If yes: custom build against self-hosted or enterprise-contracted model, no negotiation.
  3. Is the agent logic itself a competitive differentiator you intend to protect? If no: buy. If yes: build.
  4. Does your team have or can you hire someone to own evals, observability, and prompt versioning long-term? If no: buy. Custom agents without ongoing maintenance degrade silently and become liabilities.
  5. Have you actually hit the platform ceiling, or does it just feel constraining? 'We might need this later' is not a build signal. 'We tried it and here is the specific thing it cannot do' is.

This framework is blunt by design. I have seen teams spend four months and significant budget building a custom agent that a configured platform would have delivered in three weeks. The sunk cost is rarely worth the flexibility that turns out not to be needed.

What a Proper Custom Build Actually Requires

If you decide to build, go in knowing the full list. Teams underestimate the non-LLM work by a factor of three.

  • Agent loop design: How does the agent decide when to call a tool vs. respond directly? How does it handle tool failures? What is the retry policy?
  • Tool-calling and MCP integration: Each external system needs a well-specified tool definition. If you are using the Model Context Protocol (MCP), you need to build and maintain MCP server adapters for each integration. These are real engineering artifacts, not configuration files.
  • Retrieval pipeline: Chunking strategy, embedding model selection, index freshness, hybrid search (dense + sparse), re-ranking. Each decision has a measurable impact on answer quality.
  • Evals before and after every change: A suite of golden test cases with expected outputs. Without this you are flying blind. A regression in prompt wording can drop task completion rate by 20% and you will not know for weeks.
  • Guardrails: Input and output classifiers, topic restrictions, PII detection, refusal handling. Not optional for any production system touching real users.
  • Observability: Trace every LLM call, log token counts and latency, tag by agent step. Tools like LangSmith, Helicone, or a custom trace sink. You need this to debug failures and to justify model spend to stakeholders.
  • Human-in-the-loop checkpoints: Identify the steps where the agent should pause for human approval before acting. Agentic systems that act without any HITL in high-stakes flows are an incident waiting to happen.
  • Cost model: At 1,000 agent runs per day, a three-hop chain with a 4k-token context window at GPT-4o pricing is roughly $45 per day. At 50,000 runs it is $2,250 per day. Model these numbers before you commit to an architecture.

Worked Example: A Real Build-vs-Buy Decision

A fintech client came to me wanting a 'custom AI agent for contract review.' Initial ask sounded like a build. Here is how the decision played out:

What they described: Upload a supplier contract, agent flags non-standard clauses, suggests redlines, routes high-risk items to legal counsel.

First question: Does a platform do 80% of this? Yes. Several legal AI platforms (Harvey, Ironclad AI, Spellbook) handle contract review out of the box.

Second question: Any data residency constraint? Yes. Their compliance team required all contract data to stay within their AWS VPC. That eliminated the hosted platforms.

Third question: Is the agent logic a competitive differentiator? No. They are a fintech, not a legal AI company. The contract review is internal tooling.

Decision: Custom build against a self-hosted model (Llama 3.1 70B on their own AWS infra), with a purpose-built retrieval pipeline against their internal clause library, and a human-in-the-loop escalation step for any clause flagged above a risk score threshold. The build driver was compliance, not competitive differentiation.

What this required: Six weeks of engineering. A fine-tuned clause classifier. A vector index of their historical contracts for few-shot retrieval. An eval suite of 200 annotated contract segments. An approval workflow in their existing Slack tooling. The result was a system that reduced legal review time by 65% on standard contracts. But we built it because of a hard constraint, not because a platform 'felt limiting.'

What Teams Get Wrong

These are the patterns I see repeatedly:

  • Building for a future state that never arrives. 'We might need multi-agent coordination eventually' is not a reason to skip a platform today. Start constrained, identify the real ceiling, then build.
  • Confusing framework adoption with a custom build. Using LangChain is not the same as building a custom agent. It is a framework. You still have all the same operational responsibilities: evals, observability, guardrails, cost management. Many teams think they are done when the demo works. They are not.
  • No evals at launch. This is the single most common failure mode. An agent without a golden test suite is not a product, it is a prototype. Every prompt change, model update, or retrieval modification is a risk with no detection mechanism.
  • Skipping human-in-the-loop on high-stakes actions. Agents that send emails, execute transactions, or modify records should have an approval step for any action above a confidence or risk threshold. Build it in from the start. Retrofitting it is expensive.
  • Underestimating token cost at scale. A prototype that works fine at 100 runs per day becomes economically unviable at 100,000. Do the unit economics before you commit to an architecture, not after.
  • No observability until something breaks. You will not understand why your agent is failing without traces. Instrument every LLM call from day one.

Frequently Asked Questions

How much does it cost to build a custom AI agent?

A properly built production custom agent (not a prototype) typically runs $30k to $120k in engineering, depending on complexity, integrations, and whether you need fine-tuning or custom retrieval infrastructure. Ongoing cost includes model API fees (budget $500 to $5,000 per month depending on call volume), observability tooling, and maintenance. Compare that to a platform that might cost $500 to $3,000 per month with no build investment. The platform wins economically unless you have a hard constraint or the agent is your product.

Is LangChain a good choice for a custom AI agent?

LangChain is a useful framework for rapid prototyping and for teams that need flexibility without owning the agent runtime. It is a reasonable choice for Tier 3 builds. The downsides in production are real: abstraction overhead makes debugging harder, the framework moves fast and introduces breaking changes, and teams often import more of it than they actually use. For simpler agents, using the model provider SDK directly (Anthropic SDK, OpenAI SDK) with a thin wrapper you control is often more maintainable long-term.

When should I use the Model Context Protocol (MCP) for an AI agent?

Use MCP when you have multiple tools or data sources that need to be shareable across different agents or model providers, or when you want a standardized contract between your agent and its integrations. MCP makes sense for mature internal platforms where multiple teams or agent systems will consume the same tool definitions. For a single-agent system with two or three integrations, plain tool-calling with typed function definitions is simpler and easier to debug. MCP adds operational overhead. Justify it before you adopt it.

What is the difference between an AI agent and an AI workflow?

A workflow is deterministic: the steps are fixed, the branching is pre-specified, and a human defined the entire path. An agent is dynamic: the model decides which tools to call, in what order, and when to stop, based on the current state. Most business automation that gets called an 'agent' is actually a workflow with an LLM at one or two nodes. That is fine. Know which one you are building because they have different failure modes, different testing requirements, and different operational complexity profiles.

Do I need to fine-tune a model for my custom AI agent?

Rarely, at first. Fine-tuning is a significant investment and rarely the right starting point. Better retrieval, better prompts, and structured output formatting resolve the majority of quality problems without touching model weights. Fine-tune when you have a specific, high-volume task with labeled examples, when you need consistent format or tone that prompt engineering cannot reliably produce, or when you need to reduce inference cost by distilling a larger model's behavior into a smaller one. Run a retrieval and prompt optimization pass first, then evaluate whether the remaining quality gap justifies fine-tuning.

How do I know if my AI agent is working correctly in production?

You need three things: an eval suite (a set of golden test cases with expected outputs, run on every change), production tracing (every LLM call logged with inputs, outputs, token counts, and latency), and a task completion metric tracked over time. The minimum viable version is a set of 50 to 100 annotated test cases run in CI, plus a trace log you actually look at. Without these, you are operating blind. Silent quality degradation is the most common failure mode in production AI systems.

Ready to Make the Right Call?

The build-vs-buy decision for an AI agent is not about ambition. It is about constraints, timelines, and the honest answer to whether the agent loop is your product or your tooling. Most teams should start with a platform and only invest in a custom build when a real constraint or competitive moat forces the decision.

If you are at that inflection point and want a direct assessment, not a sales pitch, my AI Agent Development service starts with exactly this kind of decision session. I will tell you plainly whether to build or buy, and if you build, what it actually takes to do it right. You can also read more about my background or reach out directly to describe what you are trying to solve.

Get a direct assessment on whether to build or buy your AI agent.

Thanks for reading! I hope this was useful. If you have questions or thoughts, feel free to reach out.

Content Creation Process: This article was generated via a semi-automated workflow using AI tools. I prepared the strategic framework, including specific prompts and data sources. From there, the automation system conducted the research, analysis, and writing. The content passed through automated verification steps before being finalized and published without manual intervention.

Mahmoud Zalt

About the Author

I’m Zalt, a technologist with 16+ years of experience, passionate about designing and building AI systems that move us closer to a world where machines handle everything and humans reclaim wonder.

Let's connect if you're working on interesting AI projects, looking for technical advice or want to discuss anything.

Support this content

Share this article