LLM Fundamentals

A practical introduction to the LLM concepts I need to understand as part of my Claude Certified Architect – Foundations (CCAR-F) preparation. We'll build the mental models behind tokens, context, context windows, model input and output, and the capabilities and limitations of large language models, using simple explanations, examples, and hands-on exploration.

Before We Talk About Agents...

There are a few words that seem to appear everywhere once we enter the world of modern AI:

LLM. Generative AI. Tokens. Context window. Memory. Tools. Agents. MCP.

At first, they can start sounding like members of a very exclusive club that forgot to explain the membership rules.

The good news: we don't need to understand all of it at once. Before agents, orchestration, or architecture, we need to understand the thing sitting underneath all of it — the Large Language Model itself.

We'll start with the big picture and progressively zoom in:

The roadmap for this article A vertical chain: Generative AI, Large Language Models, Tokens, Context Window, Model Limitations, Probabilistic Behavior, Deterministic Application Logic, Architecture. Context Window also branches sideways to Context vs Memory. Generative AI Large Language Models Tokens Context Window Context vs Memory Model Limitations Probabilistic Behavior Deterministic Application Logic Architecture
Figure 1: The roadmap for this article — from generative AI down to architecture, with context and memory as a side branch.

Grab a coffee. This one's worth reading slowly — everything later in this cert leans on it. By the end of this article, we should have a mental model that we can carry into everything that follows.


1. First, What Exactly Is Generative AI?

Let's start with the broadest concept.

Generative AI refers to AI systems (or type of AI) that can generate new content in response to an input.

That content might be:

  • text
  • code
  • images
  • audio
  • video
  • structured data

We're focused on text-generating models like Claude.

Traditional Software vs. Generative AI

Consider a calculator.

We give it:

2 + 2

It gives us:

4

If we ask it again:

2 + 2

we expect:

4

There isn't much mystery involved.

We can think of traditional software roughly like this:

Traditional software: input through explicit rules to output Input points down to explicit rules, which points down to output. Input Explicit rules Output
Figure 2: Traditional software — input flows through explicit, developer-written rules to produce output.

The developer defines the rules.

Now compare that with a generative model.

We might ask:

"Explain why the sky is blue."

The system doesn't have a simple rule saying:

IF user asks about sky
THEN return sentence #47291

Instead, the LLM generates a response based on patterns it learned during training.

A simplified picture is:

A generative model: prompt through the LLM to generated text A prompt points down into the LLM, which points down to generated text. Prompt LLM Generated text
Figure 3: A generative model — the prompt goes in, and a response is generated from learned patterns, not a hard-coded rule.

This difference is incredibly important:

  • A calculator is designed around deterministic computation.
  • An LLM is designed around probabilistic generation.

Think of it this way:

  • Deterministic = Following a cake recipe exactly. We will always get the same cake.
  • Probabilistic = Describing a delicious cake to a master chef who has baked thousands of cakes. The chef knows the general principles (flour, sugar, heat), but might add a pinch more vanilla or bake it a minute longer based on instinct. We get a slightly different cake each time, but it's always recognizably a cake.
Traditional software Generative AI
2 + 2 always returns 4 Ask twice, get slightly different wording both times
Behavior is explicitly coded Behavior emerges from learned patterns
A bug is reproducible A "wrong answer" might not reproduce the same way twice
We can trace exactly why We can only reason about likely why

We'll come back to that distinction later because it becomes one of the most important architectural ideas in this entire certification.


2. AI → Machine Learning → Deep Learning → Generative AI → LLM

These terms get used interchangeably in casual conversation, but they aren't the same thing. A simple nesting picture:

Large Language Models sit inside Generative AI, inside Deep Learning, inside Machine Learning, inside AI Five nested boxes, each one contained inside the last: Artificial Intelligence, Machine Learning, Deep Learning, Generative AI, and Large Language Models at the center. Artificial Intelligence Machine Learning Deep Learning Generative AI Large Language Models
Figure 4: Large Language Models are a subset of Generative AI, which sits inside Deep Learning, inside Machine Learning, inside AI.
  • AI — the broad field of building systems that do "intelligent" tasks
  • Machine Learning — systems that learn patterns from data instead of having every rule hand-coded
  • Deep Learning — ML using neural networks with many layers
  • Generative AI — systems that generate new content, rather than just classify or select
  • Large Language Models — models trained specifically to process and generate language

Claude is a large language model, accessed through Anthropic's products and APIs. We don't need this taxonomy memorized word-for-word — we need it so that when someone says "well, technically that's deep learning, not an LLM," we're not lost.


3. So... What Is an LLM?

An LLM is a learned system that generates language based on the patterns it has learned and the information available to it at the time of generation.

Let's make that concrete.

Suppose we ask:

"Complete this sentence: The sun rises in the..."

We'd expect:

"...east."

Why?

Because the LLM has learned strong patterns connecting those words and concepts.

Now give it:

"The customer requested a refund because..."

The LLM can generate a reasonable continuation based on language patterns and the context we provide.

Suppose we ask:

"Explain why our application is returning a 500 error."

A request travels from us to the LLM, and the response travels back Three boxes: We, Our Application, and LLM. A request flows left to right along the top, from We through Our Application to the LLM. A response flows right to left along the bottom, from the LLM back through Our Application to We. request response We Our Application LLM
Figure 5: A request travels from us through our application to the LLM; the response travels the same path back.

Here's the catch: The LLM only has access to what's in that interaction. If we send just that sentence, the LLM does not magically know our logs, our database, or our deployment history. It doesn't automatically know:

  • our database state
  • today's inventory
  • our internal business rules
  • what happened in a previous conversation
  • what our application considers a valid transaction

If instead we send:

"Here is the relevant log:
ERROR: database connection timeout

Explain why our application is returning a 500 error."

Now the LLM has something to reason with. Later, if we give LLM a tool that can fetch logs itself, the architecture changes again (much more on that in a later stage).

The LLM can only work with the information available to it in the current interaction, plus whatever capabilities the surrounding system provides.

The Surrounding System

The surrounding system is everything outside the LLM that helps it be useful—the context we feed it, the memory we give it, the tools we let it use, and the guardrails we place around it.

The LLM sits inside a surrounding system of context, memory, and tools An outer frame labeled Surrounding System contains three boxes side by side — Context Window, Memory, and Tools/APIs — which feed down into an LLM box, which feeds down into a Response/Action box. SURROUNDING SYSTEM Context Window (prompt + retrieved data) Memory (short / long-term) Tools / APIs (search, DB, calculator...) LLM generates based on training patterns + whatever the surrounding system provides Response / Action
Figure 6: The LLM is only one part of the system — context, memory, and tools surround it and shape what it can do.

What the LLM alone can't do:

  • Know our database state
  • Know today's inventory
  • Know our internal business rules
  • Remember previous conversations (unless we give it memory)
  • Take actions in the real world (unless we give it tools)

What the surrounding system can provide:

  • A retrieval system that fetches relevant documents or logs
  • A memory store that remembers past conversations
  • Tools that query databases, call APIs, or take actions
  • Guardrails that enforce safety and business rules
  • Structured prompts that guide the LLM effectively

The LLM can only work with the information available to it in the current interaction, plus whatever capabilities the surrounding system provides.

This single sentence is the seed of everything we're about to cover: tokens, context, memory, and eventually tools and agents.


4. Tokens — The Actual Unit of "Reading" and "Writing"

We think in words. LLMs don't. They works with tokens — chunks of text, often smaller than a full word.

A token might be:

  • part of a word
  • a whole word
  • punctuation
  • whitespace-related text
  • or another piece of the input representation
Three words split into tokens "unbelievable" splits into un, believ, able — 3 tokens. "cat" stays whole — 1 token. "ChatGPT" splits into Chat, G, PT — 3 tokens, an unusual word. unbelievable un believ able (3 tokens) cat cat (1 token) ChatGPT Chat G PT (3 tokens — an unusual word)
Figure 7: The same idea, three different word lengths — tokens don't map cleanly to words.

The important thing to know is:

Text goes into the model as tokens, not as human-level words.

4.1 Why Should We Care About Tokens?

Tokens have practical consequences.

Tokens affect context, cost, and latency A box labeled Tokens branches down into three boxes: Context, Cost, and Latency. TOKENS Context Cost Latency
Figure 8: Why tokens matter — they directly affect context, cost, and latency.

4.1.1 Tokens Affect Context

Every piece of information we put into a model consumes part of the available context.

  • More input means more tokens.
  • More conversation history means more tokens.
  • Large documents mean more tokens.
  • Tool results mean more tokens.
  • And the model's response also uses tokens.

4.1.2 Tokens Affect Cost

For API-based applications, usage is generally measured in tokens. In other words, API usage is priced by tokens, not words or characters.

So this:

A small request keeps token usage low Small request points down to fewer tokens, which points down to less input/output usage. Small request Fewer tokens Less input/output usage
Figure 9: A small request stays cheap and fast — fewer tokens all the way down.

can be very different from:

Several inputs add up to lots of tokens Huge prompt, plus large documents, plus long history, plus large tool results, all add up to lots of tokens. Huge prompt + Large documents + Long history + Large tool results Lots of tokens
Figure 10: Stack enough inputs together and the token count adds up fast.

4.1.3 Tokens Affect Latency

More information generally means more work for the system. In other words, larger inputs/outputs generally take longer.

So:

More tokens can mean higher latency More tokens points down to more processing, which points down to potentially higher latency. More tokens More processing Potentially higher latency
Figure 11: More tokens generally mean more processing — and potentially higher latency.

This isn't an absolute rule for every system configuration, but it is an important architectural consideration.

So we don't study tokens to manually count them.

We study tokens because they determine:

  • What fits — context window limits
  • What we pay — API pricing
  • How fast it runs — latency

Tokens are the fundamental unit that ties all of these together.

We're not learning tokenization to memorize a definition. We're learning it because the amount of information we send has real, practical consequences — and that idea leads straight into the next topic.


5. The Context Window — LLM's Working Desk

If there is one analogy to remember from this entire section, let's make it this:

The context window is the LLM's working desk.

The context window is everything the LLM can "see" while generating its next response — nothing more, nothing less. Every word we send, every instruction we give, every document we attach, and every bit of conversation history we include all sit on this desk. If it's not on the desk, the LLM cannot use it.

The Desk Analogy

Let's imagine we're solving a complex problem at a desk. Spread out in front of us are:

- instructions
- notes
- reference documents
- previous discussion
- data
- relevant evidence
- calculations

Everything on the desk is immediately available. We can glance at any piece of information in a split second. That's our working memory — the information we can access without getting up, without opening a drawer, and without interrupting our flow.

Now let's imagine the desk has a physical limit. We can only fit so much on its surface. Every new document we add means something else has to move.

What happens when the desk is full?

If we bring in a new document, we have to push something off the edge. That information is no longer available to us while we're working. We've forgotten it, or at least we've lost immediate access to it.

The same is true for an LLM's context window. When we exceed the limit, the system either:

What Happens Explanation
Drops older information The system truncates the oldest content to make room for new input
Rejects the request entirely The API enforces a hard limit and returns an error

Either way, not everything can stay on the desk at once.

This is why token limits matter. Let's remember: 1 token ≈ ¾ of an English word — and every token takes up space on that desk. It's a rough guide, not a formula — this varies by language and how common the words are

What Actually Fills the Context Window?

When we say "context," we don't just mean the user's latest question. In a real application, the context window contains a mix of many things:

System instructions
        +
Conversation history
        +
Current user request
        +
Relevant documents
        +
Retrieved information
        +
Tool definitions
        +
Tool results
        +
Other application-provided information

Here's a concrete example of what a full context might look like for a customer support application:

Everything in a real customer-support request's context A box listing six items: system instructions, relevant conversation history, customer profile, order information, refund policy, and the current customer request. It points down to the LLM, which points down to the generated response. System instructions "You are a helpful support agent..." Relevant conversation history Previous 5 exchanges with the customer Customer profile Name, account tier, region Order information Order ID, date, items, total Refund policy Relevant policy section Current customer request "Where is my order?" LLM Generated response
Figure 12: A real customer-support request — everything the LLM sees before it can respond.

The LLM can use all of this information to generate a relevant, accurate response.

But here's the catch: everything in that diagram consumes tokens. The system instructions, the history, the customer profile, the policy document — they all take up space on the desk. If we add too much, the oldest items start falling off.

Context vs. Memory — They Are Not the Same Thing

This is probably one of the easiest concepts to confuse, so let's be clear about it from the start.

Let's go back to our desk analogy:

Desk = Context

But where do all our other documents live when they're not on the desk?

In a filing cabinet.

Filing cabinet = Memory

So our mental model looks like this:

Context and memory lead to different places Application branches into Context, on the desk, which points down to the LLM, and Memory, stored elsewhere, which points down to a database or storage system. Application Context "on the desk" Memory "stored elsewhere" LLM Database / Storage system
Figure 13: Context and memory lead to different places — context feeds the LLM directly; memory sits in storage until retrieved.

What's the Difference?

Aspect Context Memory
What it is Information currently on the desk Information stored in the filing cabinet
When it's available Immediately available to the LLM right now Available only when we retrieve and place it on the desk
How long it lasts Only for the current interaction (or until it falls off) Persists across sessions, days, or even years
Size limit Limited by the context window (e.g., 200K tokens) Effectively unlimited (database, vector store, etc.)
Access speed Instant Slower (requires retrieval)

Why This Distinction Matters

Let's walk through a real scenario to see context and memory in action.

Conversation 1 — the user says:

"I'm looking for running shoes. I usually prefer lightweight ones."

Our application stores this as a preference, separate from the raw chat conversation:

User preferences
----------------
Preferred category: Running shoes
Preference: Lightweight

Now the information lives in our filing cabinet (memory) — not on the desk.

Conversation 2 (the next day) — the user returns and says:

"What do you recommend?"

Here's what happens:

  1. Our application (our orchestration code) looks in the filing cabinet and retrieves the saved preference
  2. Our application places it on the desk (injects it into the new context)
  3. Our application sends everything to the LLM along with the current question
How a stored preference gets back into context Previous interaction leads to storage, which our application retrieves as a relevant preference, which becomes new context, which reaches the LLM. Previous interaction Storage Our application retrieves relevant preference New context LLM
Figure 14: The application decides what's relevant enough to bring back from memory into the current context.

Notice what happened. The LLM didn't need the entire conversation from yesterday. It needed the relevant information from yesterday. That's a much better architecture.

The LLM doesn't need to carry the entire original conversation forever — our application decides what's relevant enough to bring back from memory into the current context.

Who Decides What?

Let's be crystal clear about this:

Decision Who Makes It
What to store in memory We do (the application)
When to retrieve from memory We do (the application)
What's relevant enough to bring back We do (the application)
How to format it for the context We do (the application)
How to generate a response using that information The LLM does

The LLM doesn't decide what to retrieve. The LLM doesn't know the filing cabinet exists. We build the retrieval system. We decide what information belongs on the desk. We curate the context.

The LLM is the engine. We build the surrounding system that feeds it the right fuel at the right time.

How We Bridge the Gap

This is where techniques like Retrieval-Augmented Generation (RAG) come in. When the customer asks a question, our system:

  1. Looks in the filing cabinet (memory/database)
  2. Finds relevant information (past tickets, preferences, etc.)
  3. Places it on the desk (injects it into the context window)
  4. Now the LLM can use it to generate a response

We'll dive much deeper into these techniques later in the certification. For now, the key insight is:

Context is what the LLM can see right now. Memory is everything else. Our job as architects is to build systems that bring the right information from memory into context at the right time.

More Context Does NOT Automatically Mean Better Context

This is one of the most important lessons in our entire certification.

Scenario:

We ask the LLM:

"Where is my order?"

Useful context:

Customer name
Order ID
Current order status
Shipping status
Relevant policy

That's focused. Every piece of information is directly relevant to the question. The LLM can find what it needs quickly and generate an accurate response.

Now let's imagine we decide:

"Let's give the LLM everything. More information must be better!"

So we cram the desk with:

Entire company handbook
Entire product catalogue
Five years of customer conversations
All previous API responses
Every shipping policy ever written
Every order ever placed

Question: Did we give the model more information?

Yes.

Question: Did we give it better information?

Probably not.

We created noise. The relevant order status is buried somewhere in that pile, but the LLM now has to work through thousands of tokens of irrelevant content to find it. The useful signal is drowned out by the noise.

This is our core insight:

Relevance matters more than volume.

Our goal is never to "fill the context window." Our goal is to put the right information into the context at the right time.

Context Rot — When the Desk Gets Too Messy

Here's where the desk analogy becomes especially useful.

Let's compare these two desks:

Desk A (Focused)

Desk A — a focused context A box containing only four relevant items: order status, customer request, refund policy, and customer ID. Order status Customer request Refund policy Customer ID
Figure 15: Desk A — focused. Everything on it is relevant to the request.

Everything is relevant and easy to find. The LLM can quickly identify the key facts and generate a response.

Desk B (Overstuffed)

Desk B — an overstuffed context A box crammed with nine items: 500 pages of documentation, 300 old conversations, 1,000 API responses, product catalogue, internal handbook, old shipping policies, current order status (needed), customer request (needed), and more. The two needed items are buried among the rest. 500 pages of documentation 300 old conversations 1,000 API responses Product catalogue Internal handbook Old shipping policies Current order status — needed Customer request — needed ...
Figure 16: Desk B — overstuffed. The information we need is still there, just buried.

The important information is still there — it's just buried. Finding it and correctly using it becomes harder. The model might get distracted by irrelevant policies, outdated information, or conflicting examples.

This is our intuition behind context rot:

As context grows, irrelevant or poorly organized information can make it harder for the model to use the information that actually matters.

Context rot manifests in a few ways:

Symptom What It Looks Like
Distraction The model pulls from irrelevant sections of a large document
Omission The model misses the key fact buried in the noise
Confusion The model tries to reconcile conflicting information from old policies
Hallucination The model guesses instead of finding the needle in the haystack

So What Do We Do About This?

We can't expand the desk indefinitely. Even models with 1M+ token context windows still have limits. And even when we stay within those limits, context rot can degrade performance.

The solution isn't bigger desks. It's smarter desk management.

As we progress through this certification, we'll learn practical strategies for managing the context window:

Strategy What It Does
Context pruning Removing irrelevant or outdated information before it reaches the model
Summarization Compressing long content into concise summaries that preserve key facts
Retrieval (RAG) Fetching only the most relevant documents instead of dumping everything in
Memory systems Storing long-term information outside the context and retrieving it on demand
Tool use Letting the model call out to external systems instead of keeping everything in memory
Agentic architectures Breaking complex tasks into smaller steps with focused context windows

These are the architectural patterns that separate toy demos from production-grade systems.

Key Takeaways

Let's recap what we've learned:

Concept Takeaway
Context window The LLM's working desk — everything it can "see" at generation time
Context limit When exceeded, the system either truncates or rejects the request
Token awareness Every token consumes space on the desk; 1 token ≈ ¾ of an English word
Context vs. Memory Context is what's on the desk; memory is what's in the filing cabinet
Quality over quantity More context is not automatically better context
Context rot Too much irrelevant information degrades performance
Solution Smart context management, not bigger context windows

Now that we understand the context window — its limits, its challenges, the distinction between context and memory, and the concept of context rot — we're ready to explore practical techniques for managing it.


6. Model Limitations — The Part We Must Respect

Now we arrive at an uncomfortable truth. LLMs are incredibly capable. LLMs can summarize, explain, classify, write code, extract information, and reason over what they're given — genuinely well.

But none of these capabilities means:

"The model is guaranteed to be correct."

It's a big part of why AI-application architecture differs from traditional deterministic software.

Hallucination - When a Fluent Answer Is Wrong

What it is: The model generates information that sounds plausible but isn't actually supported by reliable information.

Example:

Imagine we ask:

"Who approved Project Phoenix?"

But we never provided any information about Project Phoenix.

The model may still generate:

"Project Phoenix was approved by Sarah in the architecture review meeting."

That sentence sounds completely reasonable. But where did Sarah come from? Maybe nowhere. It's completely made up. That's the problem.

The LLM didn't know the answer, so it invented one. Not out of malice — because it was trained to always produce a response, and "I don't know" wasn't reinforced as strongly as generating a coherent completion.

This leads to a rule worth remembering:

Fluency is not proof of accuracy.

Why this matters for us:

When we build applications, we must assume that the LLM might invent facts when it lacks information. Our surrounding system needs to validate, retrieve, or prompt in ways that discourage hallucination.

Nondeterminism / Variability

What it is: Same or similar input, not guaranteed to produce identical output each time — sometimes just phrasing differs, sometimes the substance does too.

Example:

We ask the LLM three times (with the same temperature setting):

"Summarize the benefits of regular exercise."

Attempt 1:

"Regular exercise improves cardiovascular health, strengthens muscles, and supports mental wellbeing."

Attempt 2:

"Exercising regularly can boost your heart health, build muscle strength, and improve your mood."

Attempt 3:

"Physical activity on a consistent basis benefits your heart, muscles, and mental state."

All three are accurate. All three say roughly the same thing. But the wording is different each time.

Now consider a more dangerous scenario:

We ask:

"What's the refund policy for our Premium tier?"

Attempt 1:

"Premium tier customers can request a refund within 30 days of purchase."

Attempt 2:

"Refunds for Premium tier are available for 30 days from the date of purchase."

Fine. Both are accurate.

But what about:

"Based on our conversation history, what did the customer say about the damaged item?"

If the conversation history is long and contains conflicting information, different runs might surface different details. One run might mention the shipping damage. Another might focus on the packaging. A third might combine them in unpredictable ways.

Why this matters for us:

We can't rely on the LLM giving us the exact same output every time. Our application needs to handle variability gracefully — and for critical decisions, we might need multiple passes or deterministic fallbacks.

Instruction-Following Limits

What it is: Complex, multi-part, or conflicting instructions — especially buried deep in a long prompt — can get partially ignored.

Example:

We give the LLM this prompt:

"You are a customer support agent. Follow these rules:

1. Always greet the customer by name.
2. Never mention competitor products.
3. If the customer asks about pricing, provide the standard pricing table.
4. If the customer mentions a complaint, apologize within the first sentence.
5. Keep responses under 50 words.
6. End every response with a follow-up question.
7. Never use the word 'unfortunately.'
8. Offer a discount only if the customer has been with us for over a year.
9. Use a warm, friendly tone.
10. Always reference the customer's order history."

Now the customer asks:

"Can I get a refund for this item?"

The LLM has to juggle ten distinct instructions simultaneously. What's likely to happen?

  • It might apologize (rule 4)
  • It might forget to ask a follow-up question (rule 6)
  • It might use "unfortunately" (rule 7) without noticing
  • It might completely miss the order history check (rule 10)
  • It might exceed 50 words (rule 5)

Why this matters for us:

We can't assume the LLM will follow every instruction perfectly, especially as the prompt grows. We need to:

  • Keep instructions clear and prioritized
  • Test complex prompts systematically
  • Use system-level guardrails (not just prompt instructions) for critical rules
  • Break complex tasks into smaller steps (which we'll cover in the tools and agents sections)

Knowledge and Context Limitations

What it is: The LLM may lack the information needed, or the right information might be present but poorly surfaced in a bloated context (see: context rot).

Example — Missing Information:

We ask:

"What was our total revenue in Q3 2024?"

The LLM has never seen our financial data. It doesn't know our revenue. It was trained on public internet data, not our internal systems.

What does it do?

It might say:

"I don't have access to your company's financial data. To get this information, I would need access to your internal systems or relevant reports."

Good. That's a responsible response.

But what if the information is present, just poorly surfaced?

Example — Buried Information:

We give the LLM a 500-page document containing:

  • 495 pages of general company policies
  • 1 sentence on page 398 that says: "Premium tier customers are eligible for 30-day refunds."
  • 4 pages of unrelated content

Then we ask:

"What's the refund policy for Premium tier customers?"

The LLM has the answer. It's in the context. But it's buried in noise.

Will the LLM find it consistently?

Maybe. Maybe not. It might pull from an earlier, outdated policy elsewhere in the document. It might miss the relevant sentence entirely. It might hallucinate a policy that sounds reasonable.

Why this matters for us:

We can't just dump every document into the context and hope for the best. We need to retrieve and surface the most relevant information — not overwhelm the LLM with everything we have.

This is where techniques like RAG (Retrieval-Augmented Generation) and smart context pruning become essential.

Tool-Selection Mistakes

What it is: Given several similar tools, the LLM can pick the wrong one — especially with vague or overlapping descriptions.

Example:

We give the LLM two tools:

Tool A: get_user_profile(user_id) — Returns user name, email, and preferences.

Tool B: get_user_account(user_id) — Returns user account status, billing info, and subscription tier.

Now the user asks:

"Can you tell me my email address?"

Both tools could retrieve the email. Tool A is the better choice (it returns it directly). Tool B doesn't return email at all.

Which one does the LLM pick?

If the descriptions are clear, it might pick Tool A. But if the descriptions are vague, it might pick Tool B — and then have to apologize that it can't find the email.

More subtle example:

"What plan am I on?"

Tool A returns the subscription plan. Tool B returns the user's preferences (which don't include the plan).

If the tool descriptions aren't crystal clear, the LLM might call Tool B first, fail, and then try Tool A. That's extra latency, extra cost, and a worse user experience.

Why this matters for us:

We need to design tools with clear, distinct, and specific descriptions. Vague or overlapping tool definitions confuse the LLM and lead to unnecessary calls — or worse, the wrong action.

We'll cover this in much more detail in the tools and agents section.

False Confidence

What it is: The model sounding certain is not evidence that it's correct.

Example:

We ask the LLM:

"What's the capital of Australia?"

It says confidently:

"The capital of Australia is Sydney."

It sounds certain. But it's wrong. (It's Canberra.)

Now let's increase the stakes:

"Is this transaction fraudulent?"

The LLM says:

"Yes, this transaction shows clear signs of fraud."

It sounds certain. But we have no idea how confident it actually is. The LLM doesn't have a "confidence dial." It doesn't output "I'm 72% sure." It just produces the most likely completion — and sometimes that completion is wrong.

The problem:

When an LLM is wrong, it doesn't say:

"I'm not sure, but I think it might be..."

It says:

"The answer is X."

And it says it with the same tone whether it's right or wrong.

Here's a classic example:

Question Correct Answer LLM's Wrong Answer (with false confidence)
"Who invented the telephone?" Alexander Graham Bell "Thomas Edison invented the telephone."
"What's the tallest mountain in the world?" Mount Everest "Mount Kilimanjaro is the tallest."
"Which planet is closest to the Sun?" Mercury "Venus is closest to the Sun."

In each case, the LLM sounds just as confident as when it gives a correct answer.

Why this matters for us:

Wrong instinct: "It sounded so sure, it must be right."

Right instinct: "Confidence in tone tells me nothing about accuracy. I need validation, not vibes."

The mental model shouldn't be:

The mental model we should not have Question leads to LLM leads to correct answer, presented as a guarantee, which isn't accurate. Question LLM Correct answer
Figure 17: The mental model we should not have — treating the LLM's answer as guaranteed correct.

It should be:

The mental model we should have instead Question leads to LLM leads to a generated answer, which may be useful, may be wrong, may need validation, or may need more context. Question LLM Generated answer may be useful may be wrong may need validation may need more context
Figure 18: The mental model we should have — a generated answer is a starting point, not a guarantee.
As architects, we need to build validation layers:
  • Cross-checking with known data
  • Asking for citations or sources
  • Running multiple passes and comparing results
  • Using structured outputs with confidence indicators
  • Designing workflows where humans review critical decisions

Summary of Model Limitations

Limitation In One Sentence
Hallucination The LLM can invent facts that sound plausible but aren't true.
Nondeterminism The same input can produce different outputs each time.
Instruction-following limits Complex instructions get partially ignored, especially in long prompts.
Knowledge limits The LLM doesn't know our internal data unless we provide it — and even then, it might miss what's buried.
Tool-selection mistakes Given similar tools, the LLM can pick the wrong one.
False confidence Confident tone is not a signal of accuracy.

7. Deterministic vs. Probabilistic Systems — The Big Architectural Payoff

Once we accept that LLMs are probabilistic (variable, occasionally wrong, never 100% guaranteed), a critical design question falls out naturally:

For any given piece of the system, should this be decided by LLM, or enforced by code?

This is where LLM fundamentals turn into architecture.

Let's divide responsibilities.

Good candidates for an LLM

LLMs are particularly useful for tasks involving interpretation and flexible generation:

Tasks well suited to an LLM A box titled Good For LLM, listing understanding intent, summarization, classification, drafting text, explaining concepts, extracting information, generating plans, and flexible language generation. GOOD FOR LLM Understanding intent Summarization Classification Drafting text Explaining concepts Extracting information Generating plans Flexible language generation
Figure 19: Tasks that benefit from an LLM's language understanding and flexibility.

These tasks benefit from language understanding and flexibility.


Good candidates for deterministic code

Some things should not depend solely on probabilistic generation:

Tasks that should be enforced by deterministic code A box titled Good For Code, listing authorization, security boundaries, hard business rules, database constraints, exact calculations, required validation, approval thresholds, and irreversible operations. GOOD FOR CODE Authorization Security boundaries Hard business rules Database constraints Exact calculations Required validation Approval thresholds Irreversible operations
Figure 20: Tasks that require guarantees, not probabilistic generation.

These tasks require guarantees.

Prompt-Only vs. Code-Enforced

Compare these two approaches to the same requirement:

Prompt-Only (Weak):

Please don't approve refunds over ₹50,000 without checking with a supervisor.

A prompt is a request or an instruction. It isn't necessarily a guarantee. Under unusual phrasing or a long, cluttered context, the model can still slip.

Code-Enforced (Strong):

Code-enforced: the refund threshold is a wall, not a request Customer request goes to the LLM, which understands the customer wants a refund. That goes to application logic, which checks the refund amount: 50,000 rupees or less continues automatically; more than that requires manager approval. Customer request LLM Understands: "Customer wants a refund" Application logic Check refund amount ≤ ₹50,000 → Continue > ₹50,000 → Require manager approval
Figure 21: Code-enforced — the refund threshold is a wall the application checks, not a request made to the model.

The important decision is enforced by deterministic application logic — it's a wall.

A useful rule of thumb:

Prompt = guide. Code = guarantee.

Not every prompt is weak, and not every piece of code is perfect. But when something must always happen, we should not rely solely on a model instruction.


8. A Worked Example: Putting It All Together

A customer says:

"My order hasn't arrived and I'd like a refund."

Step 1 — The application receives the request.

Step 1 — the application receives the request The customer says: my order hasn't arrived and I'd like a refund. Customer "My order hasn't arrived and I'd like a refund."
Figure 22: Step 1 — the application receives the customer's request.

Step 2 — The application gathers relevant context (not everything it has):

Customer ID · Order ID · Order status · Refund policy · Relevant prior conversation

Step 3 — That context is assembled and sent to LLM:

Step 3 — the assembled context is sent to the LLM A box listing system instructions, refund policy, order status, customer information, relevant conversation, and the new customer request, pointing down to the LLM. System instructions Refund policy Order status Customer information Relevant conversation New customer request LLM
Figure 23: Step 3 — the assembled context is sent to the LLM.

Step 4 — LLM interprets the request: "The customer is requesting a refund because the order is late."

Step 5 — Deterministic application logic checks the policy — the app doesn't just trust LLM's judgment on whether to actually process money:

The LLM interprets; the application still decides LLM identifies the request, which goes to application checks policy, which branches into eligible (continue) or not eligible (explain or escalate). LLM identifies request Application checks policy Eligible → continue Not eligible → explain / escalate
Figure 24: The LLM interprets the request; the application still decides what happens next.

Notice: LLM isn't the whole application — it's a powerful component inside one.

The LLM sits inside an application loop User goes to Application, which fans out into Context, Rules, and Validation, which converge into the LLM, which produces generated output, which goes back through Application to the user. USER Application Context Rules Validation LLM Generated output Application USER
Figure 25: The LLM sits inside a loop — context, rules, and validation go in; the application still checks the output before it reaches the user.

The surrounding application controls what context is provided, what's retrieved, what's allowed, what's validated, and what happens when the model gets it wrong. That's the beginning of thinking like an architect rather than just a prompt-writer.


9. The Six Things Worth Remembering

If everything else from this post is forgotten, keep these six:

  1. LLMs generate responses — they aren't traditional rule-based programs.
  2. Text is processed as tokens — token count has real cost, latency, and context consequences.
  3. Context is the model's current working space — instructions, history, documents, retrieved info, tool results, all competing for the same limited space.
  4. Context isn't memory — memory is persisted externally and pulled into context only when relevant.
  5. Output isn't guaranteed correct — fluent ≠ correct, confident ≠ Correct, and detailed ≠ Correct
  6. Use the right component for the right job — use deterministic code for rules, validation, and authorization. In other words, the code is better suited to guarantees.

10. The Mental Model I Want to Carry Forward

Let's compress the entire article into one picture.

The whole article in one picture User goes to the Application, which retrieves relevant data, applies rules, and builds context. Context, containing instructions, history, documents, data, and tool results, goes to the LLM, which generates. The LLM output goes back to the Application, which validates, enforces rules, and executes safely, before reaching the user. USER APPLICATION Retrieve relevant data Apply rules Build context CONTEXT Instructions History Documents Data Tool results LLM Generate LLM OUTPUT APPLICATION Validate Enforce rules Execute safely USER
Figure 26: The whole article in one picture — the application retrieves data and builds context, the LLM generates from that context, and the application validates the result before it reaches the user.

And behind all of this:

Everything about an LLM traces back to five properties LLM branches into five properties: it works with tokens, operates over context, may use retrieved memory, generates probabilistically, and therefore needs application-level boundaries and validation. LLM works with TOKENS operates over CONTEXT may use retrieved MEMORY generates PROBABILISTICALLY therefore needs APPLICATION-LEVEL boundaries and validation
Figure 27: Everything about an LLM traces back to these five properties.

That's the foundation.


11. Quick Self-Check

Before moving to the next topic, let's see if we can explain these without looking back:

  1. What is an LLM?
  2. Why do tokens matter?
  3. What is a context window?
  4. What is the difference between context and memory?
  5. Why isn't a confident answer necessarily correct?
  6. What is context rot?
  7. Which should handle this?
  8. Which should handle this?
  9. Complete the rule

Comments