CT-GENAI-900  /  Chapter 5 — Building Real Systems — Prompting, RAG, Agents, Production
Generative AI
CHAPTER 5 · ~32 MIN · CINEMATIC

Building Real Systems.

Prompting that survives contact with reality, retrieval as memory, tool-calling agents, and the cost/latency/eval/safety bill that comes due in production.

RAGretrievalprivate knowledge, no retraining
4billscost · latency · eval · safety
agentsactfrom answering to doing
32mindemo → product
ENkaraoke subs
CT-GENAI-900 · Generative AI: From Tokens to Agents
▶ VIDEO · CHAPTER 5 · ~32 MIN · CINEMATIC

Prompting, retrieval, agents — and the bill that comes due

The player screen is a live animation stage with real diagrams — prompts gain structure piece by piece, retrieval walks a real document into a real answer, an agent loops through think, act and observe, and the cost of every choice is drawn where you can see it. Karaoke subtitles in English, fullscreen.

That was the first 10 minutes.

The rest of this chapter — and chapters 2 to 5 — come with lifetime access.

$11.99one payment · lifetime access
Get the full course Already bought it? Sign in
Chapter 5 · Building Real Systems · Generative AI: From Tokens to Agents
Building Real Systems: prompt, retrieve, act — and pay
0:00 / 0:00
REFERENCE · THE MESSAGE CATALOGUE
The concept catalogue →
Every idea the chapter builds — what it is, what it does, and where it lands in the story.
REFERENCE · THE CHAPTER 5 CONCEPT CATALOGUE

Every idea in the chapter

Each concept the video builds — what it is, what it does, and where it lands in the story. Click any row to open its full breakdown. Filter to find any of them.

IdeaCategoryWhat it doesIn one lineLesson
Chapter 5 · Building Real Systems — Prompting, RAG, Agents, Production
REFERENCE · DEMO → PRODUCT

Building real systems, on one page

Everything Chapter 5 builds, as a reference you can scan: the prompt patterns that actually work, the RAG pipeline end to end, how agents act in the world, and the production triangle you will live inside.

The five prompt patterns
PatternInstead of…Do this
1 · Set a role“summarize this report”You are a senior financial analyst. Summarize this for a busy executive, in three bullets.”
2 · Provide context“give me five marketing ideas”“I am launching a budget meal kit for busy university students. Give me five marketing ideas.”
3 · Use examplesdescribing the formatshow 2–3 input/output pairs — few-shot. Showing beats telling.
4 · Constrainhoping for the right shape“reply only with valid JSON, these exact fields” · “no more than 50 words”
5 · Ask for reasoningdemanding the answerLet us think step by step.” — chain of thought
The deeper principles
Separate instructions from dataWrap the text to act upon in clear delimiters — triple quotes, XML tags — so it never confuses what to do with what to do it to.
Prefer positive instructionsNot “do not be too technical”, but “explain this so a curious twelve year old could follow it”.
System vs user promptThe system prompt sets stable, standing rules; the user prompt carries the request. Good standing rules shape every answer.
Give it an escape hatch“If the text does not contain the answer, say so.” One line, dramatically fewer confident fabrications.
SpecificityVagueness is the single greatest enemy. “Make it better” gives nothing to grip. Whenever an answer disappoints, add specific detail.
Beginning and endA model attends most strongly there. Never bury the one thing that matters most in the murky middle.
The RAG pipeline, end to end
PhaseStepWhat happens
Preparation
once
1 · collecthelp articles, manuals, policies, records — everything it should know
2 · chunkchop into pieces of a few hundred words — you want the paragraph, not the 200-page manual
3 · embedevery chunk becomes a vector — a point in the space of meaning
4 · storeinto a vector database, whose superpower is finding nearest points instantly
Live
every question
1 · embed the questionnow the question is a point in the same space
2 · similarity searchfind the chunks whose vectors sit closest — works with zero shared keywords
3 · augmentpaste those chunks into the prompt: “answer using only the information below”
4 · generateit reads from real source material instead of guessing from foggy memory

Closed book → open book. A plain model must recall everything, and bluffs when memory fails. With RAG the relevant pages are open on the desk. Retrieval quality is everything — a disappointing answer is very often a retrieval failure wearing a disguise.

Function calling and agents
The menuEach tool is described in structured text: a name (get_current_weather), a description, and the inputs it needs. Included right inside the prompt.
It has no handsThe model does not run the tool. It outputs a structured request; your code executes it and hands the real result back. The model is the brain; your tools are the hands.
The loopAn agent reasons about what to do, acts by calling a tool, observes the result, and reasons again — until the goal is done. Nobody writes the sequence.
Multi-agentA planner, a researcher, a writer, a critic — specialised agents collaborating like a real team.
Failure modesStuck in a loop · hallucinating a tool that does not exist · wandering to the wrong sub-goal · small errors compounding across steps.
GuardrailsLimit the tools · require human approval for important actions · sandbox it · keep a human accountable. Autonomy is a dial, not a switch.
The production triangle
CornerThe problemThe levers
Costtokens add up astonishingly fast — × 10,000 users a day and the bill is terrifyingcache aggressively · trim every wasted word · small models for simple tasks
Latency2 seconds feels snappy; 10 seconds feels broken and users walk awaystreaming (same total time, feels alive) · pre-compute · move slow work off the critical path
Qualitylanguage is fuzzy — there is no single correct answer to test againsta golden set of real questions + excellent answers · a strong model as judge, at scale
Safetyjailbreaks bypass your rules; prompt injection hides instructions in your own documentsfilter inputs and outputs · firm system-prompt boundaries · never act dangerously without a check
Reliabilityservices go down, requests time out, rate limits hitretries · graceful fallbacks · handle every error so the product bends instead of shattering

You can usually optimize for two, rarely all three. And then there is the last ten percent — the long tail of strange edge cases no demo reveals. Handling that gracefully is not the easy part of the work. It is the work.

Every idea in this chapter — searchable

Filter by idea, category or lesson.

Chapter 5 · the one sentence: a better prompt gets a better answer, RAG turns a closed-book exam into an open-book one, agents let the model act through your tools, and production is a deliberate trade-off between cost, latency and quality — plus the long tail that is the real work.
QUIZ · 10 QUESTIONS

Building-real-systems check

Questions and answers reshuffle every load. 70%+ and the course is yours.