The AI Internship
July 3, 2026 · 8:00 AM PDT

Foundations

Agentic AI Engineering Bootcamp · Reliable reasoning

Dr Aki Wijesundara
Dr Aki Wijesundara
Week 1
Dr Aki Wijesundara · The AI Internship01
The AI Internship
Meet your instructor

Dr Aki Wijesundara

Instructor · Agentic AI Engineering Bootcamp

  • PhD and Postdoc in Machine Learning, King's College London
  • Part of Google's AI Accelerator
  • AI Founder, SnapDrum
  • Senior AI Advisor to the United Nations
  • Previously: MIT, Oxford, Google
  • Co-founder and Lead Instructor, The AI Internship
    (10,000+ students worldwide)
Dr Aki Wijesundara · The AI Internship02
The AI Internship
Logistics · plan, tools, schedule
Five weeks, one system
01
Reasoning
02
RAG
03
Agent
04
TRACE
05
Memory

Then a two-week build sprint + Demo Day

Set up before Week 1
  • Cursor or Claude Code · your coding agent
  • OpenAI + Anthropic API keys · with credit
  • Python 3.11+ · hello-world FastAPI runs locally
Live sessions · Fridays · 8:00 AM PDT
Jul 3Wk 1 Foundations
Jul 10Wk 2 RAG
Jul 17Wk 3 Agents
Jul 24Wk 4 TRACE
Jul 31Wk 5 Memory
All live sessions are recorded - rewatch anytime in the Maven student portal
Dr Aki Wijesundara · The AI Internship03
The AI Internship
Logistics · outcomes & community
What you leave with
  • A grounded, agentic Research Assistant at a live URL
  • Schema-validated /ask → RAG → agent → evals → memory
  • A TRACE eval suite tied to real failure modes
  • A Demo Day walkthrough of the full stack

A production system, not a tutorial repo.

Join the WhatsApp group
Dr Aki Wijesundara · The AI Internship04
The AI Internship
Today's session

Week 1 agenda

~2 hours · 5 live demos · you ship /ask tonight

0
FrameReliable components vs one-off model calls
1
PlaygroundExperiment with prompts before writing code
Demo 1
2
FastAPIScaffold POST /ask with typed models
Demo 2
3
PromptingStructured outputs, few-shot, decomposition
Demo 3
4
GuardrailsValidate, retry once, reject cleanly
Demo 4
5
Token economicsCost, latency, and model selection
Demo 5
6
Ship itAssignment - a working /ask endpoint for your capstone
Dr Aki Wijesundara · The AI Internship05
The AI Internship
Segment 0 · Frame

A model call is easy.
A reliable component is engineering.

  • Anyone can get a plausible answer from a prompt once.
  • Production means: right shape, known cost, a plan for failure - every time.
  • This course is the reliability layer around a model you did not train.
A model call
prompt → answer
A reliable component
right shape
known cost
fails safely
Dr Aki Wijesundara · The AI Internship05
The AI Internship
The capstone spine

One system, built layer by layer

Today you build the reasoning core. Everything after adds to it.

Wk 1
Reasoning core
Wk 2
RAG
Wk 3
Agent
Wk 4
TRACE evals
Wk 5
Memory
→ Demo Day
Dr Aki Wijesundara · The AI Internship06
The AI Internship
What you ship today

POST /ask - question in, validated answer out

  • Schema-validated answer + tokens_used on every response.
  • Guardrail that rejects malformed output. A model choice you can defend.
Request body
"question": "…"
FastAPI endpoint
POST /ask
  1. 1Validate request schema
  2. 2Call chosen model
  3. 3Guardrail → validate response
Response body
answer
tokens_used
Dr Aki Wijesundara · The AI Internship07
The AI Internship
Segment 1 · Playground

Start in the Playground, not in code

  • Experiment before you write software. Cheaper to learn a prompt here than in a redeploy loop.
  • System message sets role and rules. User message carries the task.
OpenAI Playground
System
You are a research assistant. Answer in 3 bullets max.
User
Summarise the key findings of this paper…
Run ▶
Open now platform.openai.com/playground
Dr Aki Wijesundara · The AI Internship09
The AI Internship
The three dials that matter

Temperature · Max tokens · Token counter

Temperature
Low = consistent
High = varied
Max tokens
Ceiling on output - and on cost
Token counter
1,247
Cost as a number you watch move
Dr Aki Wijesundara · The AI Internship07
The AI Internship
Rule

Land the prompt here first.
Then take it to code.

  • Never debug prompt and plumbing at the same time.
  • Prompt behaviour becomes concrete against the real API, not theory.
Live demo 1 · ~5 min

Playground: same question at temp 0 vs 1. Lengthen the system prompt - watch the token counter. Land a working prompt to carry into code.

Dr Aki Wijesundara · The AI Internship08
The AI Internship

A prompt is not a system.
A system has an interface,
validation, and a failure plan.

You direct the agent. You read and judge every line it writes.

Dr Aki Wijesundara · The AI Internship09
The AI Internship
Segment 2 · FastAPI

Typed models = the contract

Shape in and out is defined and validated - not hoped for. Bad input rejected before the model call.

IN
Typed request
Pydantic validates first
GO
Handler
Model call lives here
OUT
Typed response
Shape defined, not hoped for
FastAPI first steps →
Dr Aki Wijesundara · The AI Internship10
The AI Internship
The /ask contract

Cost is a first-class field

Request
{ question: str }
Response
{ answer: str, tokens_used: int }
Live demo 2 · ~8 min

Scaffold FastAPI + POST /ask with Cursor / Claude Code. Read request model, model call, response model aloud. Hit it once - this is the spine everything attaches to.

Dr Aki Wijesundara · The AI Internship11
The AI Internship
Segment 3 · Prompting with rigor

Not clever wording - deterministic enough to build on

Structured outputs
JSON you can trust
Few-shot
Show the behaviour
Decomposition
Split the hard ask
Dr Aki Wijesundara · The AI Internship12
The AI Internship
Structured outputs

Chatbot → component

Chatbot
"Here's what I think… maybe…"
schema →
Component
{ answer, confidence, sources_needed }
OpenAI structured outputs →
Dr Aki Wijesundara · The AI Internship13
The AI Internship
Few-shot & decomposition
Few-shot
Show examples
Exact input-output behaviour you want. Often cheaper reliability than a longer instruction.
Decomposition
Break the hard ask
Steps the model handles reliably - not one prompt it fumbles.
Dr Aki Wijesundara · The AI Internship14
The AI Internship
Every technique has a price

Flag cost now.
Settle the bill in Segment 5.

Live demo 3 · ~6 min

Upgrade /ask to structured schema (answer, confidence, sources_needed). Show JSON in-shape. The endpoint becomes a component.

Dr Aki Wijesundara · The AI Internship15
The AI Internship

You taught the model your schema.
Now assume it sometimes won't.

Guardrails sit between model output and anything that acts on it.

Dr Aki Wijesundara · The AI Internship16
The AI Internship
Segment 4 · Guardrails

Validate · Retry · Never pass unchecked

model output
validate schema
downstream ✓

On fail: retry once → then reject cleanly

Pydantic validation →
Dr Aki Wijesundara · The AI Internship17
The AI Internship
One discipline, two directions
  • Structured output shapes the request. Guardrails defend the response.
  • Prompt injection through tool use returns in Week 3. Today: day-one fundamental.
Live demo 4 · ~5 min

Add validation + retry on malformed output. Force a failure - show the guardrail firing, not just sitting there.

Dr Aki Wijesundara · The AI Internship18
The AI Internship
Segment 5 · Token economics

Tokens = cost + latency

Treat the context window as a budget you spend on every call.

Context budget · per call
system
few-shot
question
output
× every call
Dr Aki Wijesundara · The AI Internship19
The AI Internship
Make the bill legible

Read tokens_used from your own endpoint

  • Connect it to the prompt choices you made in Segment 3.
  • Design with the budget in mind - don't discover the bill later.
Production best practices →
Dr Aki Wijesundara · The AI Internship20
The AI Internship
Model selection

Capability · Cost · Latency

Reasoning model
Capability
Cost
Latency
Fast model
Capability
Cost
Latency
Models overview →
Dr Aki Wijesundara · The AI Internship21
The AI Internship
Most systems use a mix

Strong where it matters.
Cheap everywhere else.

incoming task
router
hard → strong model
routine → cheap model
response
Live demo 5 · ~6 min

Same prompt, swap model. Watch tokens_used, latency, quality. End with one sentence: why this model for this endpoint.

Dr Aki Wijesundara · The AI Internship22
The AI Internship
Segment 6 · Ship it

Your assignment: ship /ask for your capstone

Not a toy - the reasoning core you ground in data next week.

Done when
Runs locally
Returns validated structured output
You can state per-call cost
Justified model choice
Dr Aki Wijesundara · The AI Internship23
The AI Internship

A model call is easy.
A reliable component is engineering.

Ship your /ask. Week 2 grounds it in your data.

Dr Aki Wijesundara · The AI Internship24
01 / 26
← → navigate · F fullscreen