<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Building with AI (Stage 2) on AI Vault</title><link>https://namphuongtran.github.io/ai-vault/building/</link><description>Recent content in Building with AI (Stage 2) on AI Vault</description><generator>Hugo</generator><language>en</language><atom:link href="https://namphuongtran.github.io/ai-vault/building/index.xml" rel="self" type="application/rss+xml"/><item><title>AI System Design</title><link>https://namphuongtran.github.io/ai-vault/building/ai-system-design/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/ai-system-design/</guid><description>&lt;p&gt;Building an AI feature is mostly &lt;em&gt;systems&lt;/em&gt; work — the model is one component among several.&#10;This page gives you the standard shape to build around.&lt;/p&gt;&#10;&lt;h2 id="the-big-picture"&gt;The big picture&lt;/h2&gt;&#10;&lt;pre class="mermaid"&gt;flowchart LR&#10; U[User] --&amp;gt; App[Your AI app]&#10; App --&amp;gt; Model[Model API - hosted LLM]&#10; App --&amp;gt; Data[(Your data - docs, DBs)]&lt;/pre&gt;&#10;&lt;p&gt;A user talks to your app; your app talks to a hosted model and to your data. You own&#10;everything except the model itself.&lt;/p&gt;</description></item><item><title>Scaling to Production</title><link>https://namphuongtran.github.io/ai-vault/building/scaling-to-production/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/scaling-to-production/</guid><description>&lt;h2 id="goal"&gt;Goal&lt;/h2&gt;&#10;&lt;p&gt;A working API call is the &lt;em&gt;start&lt;/em&gt;. Once an AI app has real users, new problems appear:&#10;latency climbs, token cost balloons, the model provider rate-limits you, and one failure&#10;takes the whole request down. This page is the &lt;strong&gt;advanced&lt;/strong&gt; half of&#10;&lt;a href="https://namphuongtran.github.io/ai-vault/building/ai-system-design/"&gt;AI system design&lt;/a&gt; — the infrastructure layer&#10;that makes an app fast, affordable, and reliable at scale.&lt;/p&gt;&#10;&lt;h2 id="the-story-10-users--10000-users"&gt;The story: 10 users → 10,000 users&lt;/h2&gt;&#10;&lt;p&gt;A &lt;a href="https://namphuongtran.github.io/ai-vault/hands-on/lab-rag-chatbot/"&gt;RAG chatbot&lt;/a&gt; that&amp;rsquo;s perfect for 10 users breaks&#10;in predictable ways at 10,000. Each pattern below fixes one specific break:&lt;/p&gt;</description></item><item><title>Building a RAG System</title><link>https://namphuongtran.github.io/ai-vault/building/building-rag/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/building-rag/</guid><description>&lt;p&gt;Builds on &lt;a href="https://namphuongtran.github.io/ai-vault/foundations/ground-in-data/rag/"&gt;RAG in Foundations&lt;/a&gt;. A production RAG system is &lt;strong&gt;much more&#10;than&lt;/strong&gt; &lt;em&gt;Documents → Embeddings → LLM&lt;/em&gt;. It&amp;rsquo;s &lt;strong&gt;two pipelines&lt;/strong&gt; that meet at the store — an&#10;&lt;em&gt;offline&lt;/em&gt; ingest pipeline and an &lt;em&gt;online&lt;/em&gt; query pipeline — with a chain of stages in each. The&#10;thesis to keep in mind:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;Answer quality depends far more on &lt;strong&gt;retrieval&lt;/strong&gt; than on the LLM. The model is the reasoning&#10;engine; retrieval is where the engineering happens.&lt;/p&gt;</description></item><item><title>Agentic RAG</title><link>https://namphuongtran.github.io/ai-vault/building/agentic-rag/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/agentic-rag/</guid><description>&lt;p&gt;Builds on &lt;a href="https://namphuongtran.github.io/ai-vault/foundations/make-it-act/agentic-ai/"&gt;Agentic AI&lt;/a&gt; and&#10;&lt;a href="https://namphuongtran.github.io/ai-vault/deep-dives/types-of-rag/"&gt;Types of RAG&lt;/a&gt;. In &lt;strong&gt;standard RAG&lt;/strong&gt; the pipeline is&#10;fixed — always retrieve once, then generate. &lt;strong&gt;Agentic RAG&lt;/strong&gt; hands that control to an&#10;&lt;a href="https://namphuongtran.github.io/ai-vault/foundations/make-it-act/agents/"&gt;agent&lt;/a&gt;: it decides &lt;em&gt;whether&lt;/em&gt;, &lt;em&gt;what&lt;/em&gt;, and &lt;em&gt;how often&lt;/em&gt; to&#10;retrieve, using retrieval as a tool.&lt;/p&gt;&#10;&lt;h2 id="standard-vs-agentic"&gt;Standard vs. agentic&lt;/h2&gt;&#10;&lt;pre class="mermaid"&gt;flowchart LR&#10; Q1[Question] --&amp;gt; R1[Retrieve once] --&amp;gt; G1[Generate] --&amp;gt; A1[Answer]&lt;/pre&gt;&#10;&lt;p&gt;Standard RAG, above, is one fixed pass. Agentic RAG, below, is a loop the agent controls:&lt;/p&gt;&#10;&lt;pre class="mermaid"&gt;flowchart TD&#10; Q[Question] --&amp;gt; A[Agent reasons]&#10; A --&amp;gt; D{Need to retrieve?}&#10; D --&amp;gt;|no| Ans[Answer]&#10; D --&amp;gt;|yes| R[Pick query &amp;#43; source, retrieve]&#10; R --&amp;gt; C{Enough to answer?}&#10; C --&amp;gt;|no| A&#10; C --&amp;gt;|yes| Ans&lt;/pre&gt;&#10;&lt;h2 id="what-the-agent-decides"&gt;What the agent decides&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Whether&lt;/strong&gt; to retrieve at all — some questions don&amp;rsquo;t need it.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;What&lt;/strong&gt; query to use — often a rewrite of the user&amp;rsquo;s question, or several sub-queries.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Which source&lt;/strong&gt; — different vector stores, a web search, a database, an API.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;How many rounds&lt;/strong&gt; — retrieve, read, then retrieve again for a follow-up fact (multi-hop).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Whether the context is enough&lt;/strong&gt; — re-retrieve or ask for clarification if not.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Retrieval becomes a &lt;a href="https://namphuongtran.github.io/ai-vault/foundations/make-it-act/tool-function-calling/"&gt;tool&lt;/a&gt; the agent calls,&#10;not a fixed first step.&lt;/p&gt;</description></item><item><title>The Agent Harness</title><link>https://namphuongtran.github.io/ai-vault/building/agent-harness/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/agent-harness/</guid><description>&lt;p&gt;Builds on &lt;a href="https://namphuongtran.github.io/ai-vault/foundations/make-it-act/agentic-ai/"&gt;Agentic AI&lt;/a&gt;. The model is the engine; the&#10;&lt;strong&gt;harness&lt;/strong&gt; is everything around it that turns a single model call into a working agent. This&#10;page is how one is built.&lt;/p&gt;&#10;&lt;h2 id="what-the-harness-owns"&gt;What the harness owns&lt;/h2&gt;&#10;&lt;pre class="mermaid"&gt;flowchart LR&#10; subgraph Harness&#10; Loop[Agent loop]&#10; CtxM[Context manager]&#10; ToolR[Tool executor]&#10; Mem[Memory]&#10; Guard[Guardrails / permissions]&#10; end&#10; Harness --&amp;gt; Model[Model API]&#10; Harness --&amp;gt; Tools[Tools]&lt;/pre&gt;&#10;&lt;h2 id="the-loop"&gt;The loop&lt;/h2&gt;&#10;&lt;p&gt;At its core the harness runs one loop until the task is done:&lt;/p&gt;</description></item><item><title>From Prompts to Graphs</title><link>https://namphuongtran.github.io/ai-vault/building/engineering-disciplines/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/engineering-disciplines/</guid><description>&lt;h2 id="goal"&gt;Goal&lt;/h2&gt;&#10;&lt;p&gt;Make sense of the vocabulary explosion: &lt;strong&gt;prompt → context → harness → loop → graph&#10;engineering&lt;/strong&gt;, five terms in about five years. This page places them on one timeline, gives&#10;one worked example per era, and shows the structural line that separates them — so the next&#10;new &amp;ldquo;-engineering&amp;rdquo; term lands in a mental model instead of adding to the confusion.&lt;/p&gt;&#10;&lt;h2 id="the-one-distinction-that-organizes-all-five"&gt;The one distinction that organizes all five&lt;/h2&gt;&#10;&lt;p&gt;Each discipline exists because the previous one hit a wall. But they split cleanly into two&#10;groups:&lt;/p&gt;</description></item><item><title>AI Code Structure</title><link>https://namphuongtran.github.io/ai-vault/building/ai-code-structure/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/ai-code-structure/</guid><description>&lt;p&gt;An AI app has more moving parts than a normal service — prompts, tools, retrieval, guardrails,&#10;evals. Cramming them into one file makes them impossible to test or change. A little structure&#10;keeps each concern separate and swappable.&lt;/p&gt;&#10;&lt;h2 id="a-suggested-layout"&gt;A suggested layout&lt;/h2&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;app/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;├── prompts/ # versioned prompt templates (not inline strings)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;├── tools/ # tool definitions + handlers, one per tool&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;├── retrieval/ # ingestion + query: chunk, embed, vector store&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;├── orchestrator/ # the harness: assemble context, run the loop&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;├── guardrails/ # input/output checks, PII redaction&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;├── evals/ # eval sets + runners (run in CI)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;├── observability/ # tracing, logging, metrics&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;├── clients/ # model API client(s)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;└── config/ # settings, model ids — no secrets in code&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="how-the-pieces-depend"&gt;How the pieces depend&lt;/h2&gt;&#10;&lt;pre class="mermaid"&gt;flowchart TD&#10; Orch[Orchestrator] --&amp;gt; Prompts[Prompts]&#10; Orch --&amp;gt; Tools[Tools]&#10; Orch --&amp;gt; Retrieval[Retrieval]&#10; Orch --&amp;gt; Guard[Guardrails]&#10; Orch --&amp;gt; Client[Model client]&#10; Evals[Evals] -. test .-&amp;gt; Orch&#10; Obs[Observability] -. wrap .-&amp;gt; Orch&lt;/pre&gt;&#10;&lt;h2 id="principles"&gt;Principles&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Prompts are files, not string literals&lt;/strong&gt; — version them, diff them, test them (see&#10;&lt;a href="https://namphuongtran.github.io/ai-vault/foundations/work-with-models/prompt-engineering/"&gt;Prompt engineering&lt;/a&gt;).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;One tool = one module&lt;/strong&gt; — a definition + a handler you can test in isolation (see&#10;&lt;a href="https://namphuongtran.github.io/ai-vault/foundations/make-it-act/tool-function-calling/"&gt;Tool &amp;amp; function calling&lt;/a&gt;).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Keep retrieval separate&lt;/strong&gt; — the &lt;a href="https://namphuongtran.github.io/ai-vault/building/building-rag/"&gt;ingest and query pipelines&lt;/a&gt;&#10;are their own layer, not tangled into the orchestrator.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;A thin orchestrator&lt;/strong&gt; — the &lt;a href="https://namphuongtran.github.io/ai-vault/building/agent-harness/"&gt;harness&lt;/a&gt; just wires&#10;the pieces together; keep logic in the pieces.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Evals are first-class&lt;/strong&gt; — an &lt;a href="https://namphuongtran.github.io/ai-vault/deep-dives/evaluation-in-practice/"&gt;eval set&lt;/a&gt;&#10;is your test suite; run it in CI on every prompt or model change.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Config and secrets out of code&lt;/strong&gt; — model ids and settings in config; secrets in the&#10;environment, never in prompts or the repo.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="why-it-pays-off"&gt;Why it pays off&lt;/h2&gt;&#10;&lt;p&gt;When retrieval quality drops, you swap models, or a prompt regresses, you change &lt;em&gt;one&lt;/em&gt; place —&#10;and your evals tell you whether it worked, instead of hunting through a monolith.&lt;/p&gt;</description></item><item><title>Tooling &amp; Frameworks</title><link>https://namphuongtran.github.io/ai-vault/building/tooling-and-frameworks/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/tooling-and-frameworks/</guid><description>&lt;p&gt;Expands the &amp;ldquo;build vs. buy&amp;rdquo; note from&#10;&lt;a href="https://namphuongtran.github.io/ai-vault/building/agent-harness/"&gt;The agent harness&lt;/a&gt;. You rarely build an agent from&#10;scratch — there&amp;rsquo;s a ladder from &lt;em&gt;write everything&lt;/em&gt; to &lt;em&gt;a provider runs it for you&lt;/em&gt;.&lt;/p&gt;&#10;&lt;h2 id="four-ways-to-build-an-agent"&gt;Four ways to build an agent&lt;/h2&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Approach&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;You write&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Harness &amp;amp; hosting&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Reach for it when&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Manual loop&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;the reason → act → observe loop yourself&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;you build + you host&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;you want total control, no dependency&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;SDK tool runner&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;just your tool functions&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;SDK runs the loop; you host&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;a custom-tool agent without hand-writing the loop&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Agent SDK&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;a prompt + config&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;SDK is a full harness with built-in tools; you host&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;a batteries-included coding / file agent on your infra&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Managed service&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;agent config + tool results&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;provider runs the loop &lt;em&gt;and&lt;/em&gt; hosts a sandbox&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;you want no infra: hosted, stateful, scheduled&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;Concrete examples: the &lt;strong&gt;Anthropic API SDK&amp;rsquo;s Tool Runner&lt;/strong&gt; (&lt;code&gt;client.beta.messages.tool_runner&lt;/code&gt;)&#10;is a tool runner; the &lt;strong&gt;Claude Agent SDK&lt;/strong&gt; is an Agent SDK (Claude Code packaged as a library);&#10;&lt;strong&gt;Anthropic Managed Agents&lt;/strong&gt; is a managed service.&lt;/p&gt;</description></item></channel></rss>