Sub topic 7
Follow Up on the Parts You Don't Understand
The first answer from an assistant is rarely the last one you need. This chapter covers how to turn a partly understood explanation into a fully understood one by asking narrow, well-aimed follow-up questions.
It assumes you can already write a clear explanation prompt, read a response critically, and run small Python snippets locally. It reuses the lru_cache example from earlier chapters.
Why follow-ups beat re-asking
When part of an explanation is unclear, many people paste the whole question again, or type "I don't get it". Both approaches throw away information. The assistant cannot tell which sentence lost you, so it usually repeats the same explanation with different wording.
A good follow-up has three properties:
- It points at a specific claim, line, or term from the previous answer.
- It names what kind of gap you have: a word, a mechanism, a reason, or trust.
- It asks for one kind of output: a trace, an example, a comparison, or a source of evidence.
The conversation then becomes a loop. You read, find the weakest point, ask about that point, and check the result.
Classify the gap before you ask
Different gaps need different questions. Decide which one you have first.
| Gap | What it feels like | Follow-up pattern |
|---|---|---|
| Vocabulary | A term in the answer is unfamiliar | "Define X in one sentence, then show it in this code." |
| Mechanism | You see what happens but not how | "Trace the call with concrete values." |
| Rationale | You see how it works but not why it is there | "What would break or get slower if I removed this line?" |
| Scope | You do not know where the behavior ends | "What are the inputs for which this does not hold?" |
| Trust | The answer sounds plausible but you cannot tell if it is right | "Which of these claims depend on version or configuration? How can I test each one?" |
Most confusion is one of these five. If you cannot classify it, say so: "I follow the first paragraph but lose it at the sentence about cache keys." That is already more useful than "explain more".
Quote the part you are asking about
Copy the exact phrase and ask about it. This prevents the assistant from guessing which part you meant, and it makes vague answers easier to spot.
Suppose the first answer to the fib prompt included this sentence: "The cache is keyed on the function's arguments, so repeated calls are cheap." Two follow-ups are possible.
A weak one:
I don't understand the cache part.A strong one:
You wrote: "The cache is keyed on the function's arguments."
Where is that cache stored, and what exactly is the key when I call fib(5)?
Does fib(5) and fib(5.0) hit the same entry? Say whether you know this
or are inferring it, and give me a way to check.The strong version quotes the claim, asks two concrete questions, and asks the assistant to separate knowledge from inference. It also asks for a check, which feeds the next chapter.
Common follow-up patterns
Ask for a trace with real values
Abstract explanations hide errors. A trace forces the assistant to commit to specifics that you can compare with reality.
Trace fib(5) with the decorator in place. List each call in order and mark
each one as a cache miss or a cache hit. Give the total number of misses
and hits at the end.The assistant's answer is now checkable. Without the cache, fib(5) makes 15 calls. With it, the trace should show 9 calls: 6 misses (for n from 5 down to 0) and 3 hits. If the assistant gives different numbers, you have found either a mistake in the answer or a gap in your reading.
Ask "what if I remove it"
Rationale questions are best asked as counterfactuals.
What changes if I delete the @lru_cache line? Compare the number of calls
for fib(30) with and without it, and say what happens to memory use.This usually surfaces the exponential versus linear call count. It also surfaces the memory cost of maxsize=None, which means the cache is unbounded.
Ask for the smallest example
If an answer relies on a concept you cannot picture, ask for the smallest runnable demonstration.
Show me the smallest runnable example of a function where using lru_cache
gives a wrong result because of a side effect. Keep it under 10 lines.The result is something you can run, not just read.
Ask for a contrast with something you know
Mapping to familiar ground speeds up learning.
I know manual memoization with a dict. Show the same fib written with a
dict, and list the differences from lru_cache.Ask about edge cases and limits
Explanations tend to describe the happy path. Ask where it stops working.
What happens for a very large n, such as fib(5000)? What happens if the
argument is a list? Explain each case in one or two sentences.These questions lead to genuine gotchas. Recursion depth limits can make large inputs fail with a RecursionError. Unhashable arguments such as lists cannot be used as cache keys, so the call raises a TypeError. Both claims are testable in seconds.
Pushing back without breaking the answer
When something sounds wrong, resist typing "Are you sure?". Assistants often respond to doubt by reversing an answer that was correct, or by adding hedges that carry no information. A more reliable approach is to ask for evidence, not reassurance.
| Instead of | Try |
|---|---|
| "Are you sure?" | "What would I see if that were false? Give me a test." |
| "That's wrong." | "I got X when I ran it. Explain the difference between X and your claim." |
| "Explain again." | "Explain only the second step, with values." |
When you report your own result, include the exact code and output. That gives the assistant something concrete to reconcile with its earlier explanation.
I ran this and got CacheInfo(hits=3, misses=6, maxsize=None, currsize=6)
after calling fib(5). Your trace said 4 hits. Which one is right, and where
did your trace go wrong?Signals that a follow-up is needed
Some phrasing in an answer should prompt a question even if you think you understood it.
- Vague verbs. "Handles", "takes care of", "just wraps" hide the actual mechanism. Ask what exactly happens.
- Hedge words with no detail. "Typically", "usually", and "in most cases" hide the exceptions. Ask for the cases that are not typical.
- Version-dependent claims. Statements about default behavior or recent features may depend on the interpreter version. Ask which versions the claim holds for.
- Claims about code you did not show. If the assistant describes what an imported helper does and you did not paste it, it is guessing. Ask what it is basing that on.
- Inconsistency between turns. If the second answer contradicts the first, ask it to name which answer it now believes and why. Then check.
A worked session
Here is a compact session built around the running example.
from functools import lru_cache
@lru_cache(maxsize=None)
def fib(n):
return n if n < 2 else fib(n - 1) + fib(n - 2)
print(fib(5))
print(fib.cache_info())Turn 1 (your question): "Why is the decorator there?"
Turn 1 (assistant): "It memoizes results, so fib runs in roughly linear time instead of exponential time."
You mark the word memoizes as vocabulary and the phrase roughly linear as vague.
Turn 2 (your follow-up):
You said it "memoizes results" and runs in "roughly linear time".
Define memoize in one sentence. Then show how many times the function body
runs for fib(5) with and without the decorator, as a list of calls.Turn 2 (assistant): It defines memoization as storing the result for a given input and reusing it. It lists 15 calls without the decorator and 9 with it, of which 6 run the body.
Check: Run the snippet above. It prints 5, then CacheInfo(hits=3, misses=6, maxsize=None, currsize=6). The misses equal the number of times the body ran, and hits plus misses equal 9 total calls. The assistant's claim matches.
Turn 3 (rationale): "What is the downside of maxsize=None?" The expected answer is that the cache grows without bound as new arguments arrive. For a long-running process fed many distinct inputs, a bounded size such as maxsize=128 evicts the least recently used entries instead.
At each turn, the question named a specific term or number, and the answer could be compared with something observable.
Keeping the conversation healthy
- One question per turn. Several questions in one message tend to get shallow answers to each of them.
- Keep the code in view. In long conversations, re-paste the relevant lines when you ask about them. Earlier code may drop out of the assistant's working context, and then it may answer from memory of the pattern, not from your code.
- Restart when it drifts. If the conversation has accumulated contradictions, start a new one with a short summary of what you have confirmed and the one question still open.
- Say what you already know. "I understand decorators in general" saves you from a repeated introduction.
- Stop when it is clear. Once you can explain the code in your own words and the checkable claims have passed, further questions add noise.
Common errors
- Asking "explain more" and getting the same explanation again, with more words. Name the sentence instead.
- Accepting a confident trace without comparing it to a real run. A trace is a claim, so test it.
- Asking about the whole file when one line is the problem.
- Treating a changed answer as a corrected answer. After pushback the assistant may be agreeing with you, not fixing a mistake. Look for evidence either way.
- Skipping the follow-up on a hedge word because the overall answer sounds fine.
Exercise
An assistant explains the lru_cache version of fib and says "the cache makes everything fast." Rewrite this as one follow-up that quotes the claim, classifies the gap, and asks for something checkable.
Show answer
A good answer quotes "makes everything fast", identifies the gap as scope (when is it not fast?), and asks for a checkable output. For example: "You said 'the cache makes everything fast.' Which calls are fast and which are not? Give me the hit and miss counts for fib(5) on the first call and on a second identical call, and tell me what cache_info() should print." The second call should add hits only and no new misses, which you can confirm by running it.
Exercise
You run the fib snippet and see CacheInfo(hits=3, misses=6, maxsize=None, currsize=6), but the assistant's trace said 4 hits and 5 misses. Write a follow-up that avoids "Are you sure?" and gives the assistant what it needs to find the discrepancy.
Show answer
Report the exact output and ask for a reconciliation, for example: "I ran fib(5) and cache_info() printed hits=3, misses=6. Your trace said 4 hits and 5 misses. Recount your trace call by call, mark each call as hit or miss, and show where it first differs from my result." The key elements are the exact observed output, the specific claim it contradicts, and a request for a call-by-call recount.