Pillar guide · 12 min read

    How to build an AI agent

    The architecture, the tool loop, the eval discipline, and the deployment path for a solo builder who wants an agent that does real work for real customers.

    By Usman Jatoi, Founder, Build on Vibe Reviewed by Usman Jatoi Updated 2026-07-06 · 12 min read

    An AI agent is not a chatbot. It's a program that plans, calls tools, observes results, and iterates toward a goal you gave it in English. In 2026, the interesting agents are narrow: they replace a specific workflow (inbox triage, SEO audits, invoice reconciliation) for a specific customer, and they get paid monthly to keep doing it.

    This guide is the practical version enough theory to make decisions, then a build path you can actually finish in 30 days.

    PromptRun ObserveRefine
    The agent loop. Plan → Act (tool call) → Observe → Refine. Same loop as vibe coding, run by the model itself.

    What an agent actually is

    An agent = model + tools + loop + goal. Take away the tools and it's a chatbot. Take away the loop and it's a single completion. The interesting part and the hard part is the loop: knowing when to stop, when to ask, and when to fail loudly.

    The 2026 agent stack

    • Model GPT-5, Claude 4, or Gemini 2.5 via Lovable AI Gateway (no key management).
    • Framework Vercel AI SDK or LangGraph. Skip heavier frameworks until you feel their absence.
    • Tools HTTP fetch, your own DB, and 1-3 first-party APIs. Every tool is an attack surface validate inputs and outputs.
    • Memory Postgres + pgvector on Supabase. Start with conversation summaries; add embeddings only when recall actually matters.
    • Evals a folder of .jsonl cases, run in CI on every deploy. Non-negotiable.
    • Deploy Supabase Edge Functions or a small Node service. Add a per-request cost cap on day one.

    Anatomy of the loop

    1. Plan model reads goal + state, emits next tool call as structured JSON.
    2. Act your code executes the tool. Validate args against a schema first.
    3. Observe feed the result back into the prompt as a compact JSON message.
    4. Refine model decides: another tool call, ask user, or finish.

    Guardrails that make this safe in production: max steps (e.g. 8), cost cap per run, timeout per tool, and an explicit ‘give up and ask' branch.

    Inside the workspace

    Pillar AI app guide on Build on Vibe
    Interlinked with the ‘Build an app with AI' pillar agents are one deployment shape of the same stack.
    Directory of AI models and tools
    The directory catalogs every model and tool referenced in this guide, with fit notes for solo builders.
    Original data · Build on Vibe

    What kills agent projects in production

    Fail on unbounded tool loops
    42%

    No max-steps, no cost cap

    Fail on hallucinated tool args
    28%

    Fixed with structured outputs + schema validation

    Fail on missing evals
    19%

    No regression tests before deploys

    Ship + reach paying customer
    24%

    The disciplined 24%

    Methodology. Post-mortem review of 168 agent projects built on Build on Vibe, Jan-Jun 2026.

    Sources: Build on Vibe agent cohort

    Build your first shipping agent

    1. 1
      Day 1-2 · Pick one workflow

      Not ‘assistant'. One workflow. ‘Turn any Stripe dispute email into a drafted response with evidence attached.' The narrower, the better.

    2. 2
      Day 3-5 · Design the tool set

      3-6 tools max. Each has a JSON schema for args and a JSON schema for its response. Write them before you write prompts.

    3. 3
      Day 6-8 · Ship v0 (single-shot)

      No loop yet. One prompt, one tool call, return result. Prove the shape works end-to-end.

    4. 4
      Day 9-14 · Add the loop + guardrails

      Max steps, cost cap, timeout, structured-output validation. Log every step to Postgres for review.

    5. 5
      Day 15-20 · Build the eval set

      20 real examples with expected outputs. Run in CI. No deploy without a passing eval run.

    6. 6
      Day 21-30 · Wrap in a UI + Stripe

      Auth, a run history view, per-run cost display, and a subscription. Ship to 5 real users. Price at 10-30× your per-run cost.

    FAQ

    Do I need LangChain or LangGraph?

    Not for a first agent. The Vercel AI SDK plus your own loop is 200 lines and easier to debug. Reach for a framework when you have real multi-agent branching.

    How do I stop runaway costs?

    Hard cap per run (e.g. $0.20), hard cap per user per day, and a circuit breaker on your model provider's spend. Set these on Day 1.

    Which model should I use?

    Whichever the Lovable AI Gateway routes to for your tier. Ship first, then A/B smaller/cheaper models against your eval set.

    How much should I charge?

    10-30× your per-run cost, packaged as a subscription with a monthly run allowance. Nobody wants to think about tokens.

    Is this a real business or a demo?

    Real, if it does a specific job for a specific customer. Generic ‘AI assistant' agents don't retain narrow workflow agents do.

    Keep reading

    Sources

    Ready to actually ship?

    Build on Vibe gives you the workflow, prompts, and evidence gates that get finishers across the line.