Module 2 · Building Agents · scripted
Where Does an Agent Get the Information It Needs?
Overview
When an LLM produces a response, it reasons from the context it has at that moment. Sometimes that context can be assembled before reasoning begins. Other times, figuring out what context is needed — and going to get it — is part of the reasoning problem itself. In this lesson we watch an agent move from reasoning over provided context to acquiring context of its own, name the three questions that determine how hard that is, and arrive at the central idea: an agent helps construct the context required for its own reasoning.
Reasoning from what you have
When an LLM produces a response, it reasons from the context it has at that moment. Suppose we give it a prompt that already contains the complete transcript of a meeting about an upcoming trip to Molde, Norway, and ask it to identify important gaps in the plan. The context is already available. The LLM's job is to apply computational thought to what is already in front of it.
Here is the transcript of our meeting about an upcoming trip to Molde, Norway. Identify important gaps in our plan.
[full meeting transcript: flights, hotels, clothing, transportation]
You discussed flights, hotels, clothing, and transportation, but never discussed passports. Norway is an international destination for you — that is an important gap.
This is a self-contained reasoning task. Context goes in, reasoning happens, an answer comes out.
Reasoning over provided context
When the answer is not in the context
Now consider a different request about the same trip: "Look through our trip-planning materials and determine whether we remembered to check our passports." The answer is not in the starting context. The agent must acquire information before it can answer.
You have the following tools available for use:
- read_file( path )
- search_notes( query )
Task: Look through our trip-planning materials in packing-list.txt and determine whether we remembered to check our passports.
read_file(path = "packing-list.txt")Warm jacket, hiking boots, rain gear, camera, chargers, medications.search_notes(query = "passport")No matches in the meeting notes.Passports do not appear on the packing list, and the meeting notes never mention them. We did not remember to check our passports.
The loop is different now. The agent reasons, decides it needs something, acquires it, observes the result, and reasons again.
The acquisition loop
Three tasks, three difficulties
Sometimes the context necessary to solve a problem can be assembled before reasoning begins. Other times, figuring out what context is needed and acquiring it is part of the reasoning problem itself. Three versions of the same errand show the ladder.
Task A — we know what information we need and where to find it.
You have the following tools available for use:
- read_file( path )
Task: Look at our packing list and tell me whether passports are listed.
read_file(path = "packing-list.txt")Warm jacket, hiking boots, rain gear, camera, chargers, medications.No. Passports are not on the packing list.
Task B — we know what we are looking for, but not where it is.
You have the following tools available for use:
- read_file( path )
- search_notes( query )
Task: Search our trip-planning materials and determine whether we ever discussed passports.
search_notes(query = "passport")No matches in the meeting notes.read_file(path = "packing-list.txt")Warm jacket, hiking boots, rain gear, camera, chargers, medications.No. Passports appear nowhere in the meeting notes or the packing list. We never discussed them.
Task C — even what the agent should look for is part of the problem.
You have the following tools available for use:
- read_file( path )
- search_notes( query )
Task: Review our trip plans and identify anything important we have forgotten.
read_file(path = "itinerary.txt")Fly Nashville to Molde via Amsterdam. Rental car at the airport. Day 3:
hike ending in Eresfjord, 40 km from the hotel.think(thought = "The trip crosses an international border — that
suggests investigating passports. We plan to rent a car — that suggests
driver's-license requirements. And the day-3 hike ends far from the
hotel — that suggests return transportation.")OK.search_notes(query = "passport OR license OR return transport")No matches for any of these in the meeting notes.Three important gaps: passports were never checked, we never confirmed our licenses are valid for driving in Norway, and there is no plan for getting back from the day-3 hike.
The ladder of difficulty
In Task C, the agent is reasoning about what information it needs next.
The hardest tasks are the ones where the agent must figure out what to look for, not just where to look.
Three questions
Three questions determine much of the difficulty of any information-gathering task.
Three questions
Each "no" makes the task harder.
A task where all three answers are yes is a lookup; a task where all three are no is an investigation.
Three ways information enters
Searching is not always enough. Suppose the task is: "Determine whether the conference venue is quiet enough to record interviews in the afternoon." The venue's website might describe the rooms. Reviews might discuss noise. But perhaps nobody has ever measured the actual afternoon noise level in that room. The information does not yet exist in a form we can retrieve. Someone has to go into the room in the afternoon and produce the observation.
Three ways information enters context
In the acquired case the agent is not finding an existing answer. It is causing new information to be created.
You have the following tools available for use:
- search_documents( query )
- send_email( to, message )
Task: Determine whether the supplier can deliver 500 units by Friday.
search_documents(query = "supplier delivery capacity 500 units")No document answers this. Past orders show 200-unit deliveries.send_email(to = "orders@supplier.com", message = "Can you deliver 500
units by this Friday?")Reply received: "Yes — 500 units by Friday is possible with two-day
notice."Yes. No record answered the question, so I asked the supplier directly. They confirmed 500 units by Friday with two-day notice.
Investigation is iterative
Discovery can take many steps, and each step decides the next. A manager asks: "Figure out why sales at our downtown store fell sharply last month." Each observation changes what the agent investigates next.
You have the following tools available for use:
- query_sales( filter )
- search_records( query )
Task: Figure out why sales at our downtown store fell sharply last month.
query_sales(filter = "downtown, by day of week")The decline happened primarily on weekends.think(thought = "Weekends — was staffing different on weekends?")OK.search_records(query = "weekend staffing changes downtown")No major staffing changes last month.query_sales(filter = "downtown, weekends, by product category and hour")Most of the decline came from lunchtime purchases.think(thought = "Lunchtime, weekends. Something outside the store —
nearby events, transportation, competing businesses?")OK.search_records(query = "downtown area construction closures last month")The parking garage beside the store was closed for construction.The sales decline traces to the parking garage beside the store: it was closed for construction, and weekend lunchtime customers who drive had nowhere to park.
Acquisition depth
A direct lookup is one step. An open investigation can be ten, twenty, or more — and each observation decides the next search.
Acting to learn, acting to change
An agent might call a hotel and ask, "Do you have 40 rooms available on August 26?" The purpose is to learn something. Later it might say, "Reserve those 40 rooms." The purpose is to change something in the world. Some actions exist to learn; others exist to change the world.
Two kinds of action
After changing the world, the agent confirms the change actually happened. The confirmation step is epistemic again.
Choosing what to investigate
An agent with tools always has many possible next actions. Suppose a restaurant owner asks it to figure out why customers wait so long for lunch orders. The agent could read another 500 customer reviews, or spend 30 minutes timing each stage of ten lunch orders. If the question is where the delay occurs, timing the orders answers it far more efficiently. A good next action is the one that reduces the most uncertainty for its cost.
Choosing the next action
A good next action reduces the most uncertainty for its cost.
Cost can be money, time, inconvenience, risk, or the attention of another person. A good agent does not merely have tools. It reasons about which action is worth taking next.
The central idea
A traditional prompt assumes someone has already assembled the context the LLM needs. An agent can do something more powerful.
The central idea
An agent can reason about what context it needs and how to acquire it.
It does not just reason over context — it helps construct the context required for its own reasoning.
That is why agents need tools, search, and loops.