Σ 0:00▸ 0:00

Module 2 · Building Agents · scripted

Where Does an Agent Get the Information It Needs?

25 minoutcomes: context-engineering

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.

The transcript is already in the prompt
user

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]

assistant

You discussed flights, hotels, clothing, and transportation, but never discussed passports. Norway is an international destination for you — that is an important gap.

✎ noteThe answer came from reasoning alone. Nothing was fetched; everything needed was in the prompt.

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.

The agent must go get the answer
user

You have the following tools available for use:


  1. read_file( path )
  2. search_notes( query )

Task: Look through our trip-planning materials in packing-list.txt and determine whether we remembered to check our passports.

assistant
read_file(path = "packing-list.txt")
user
Warm jacket, hiking boots, rain gear, camera, chargers, medications.
assistant
search_notes(query = "passport")
user
No matches in the meeting notes.
assistant

Passports do not appear on the packing list, and the meeting notes never mention them. We did not remember to check our passports.

✎ noteEach result gave the agent information it did not previously have. The observation became part of the next context, and the agent reasoned again.

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.

Task A · Known information, known location
user

You have the following tools available for use:


  1. read_file( path )

Task: Look at our packing list and tell me whether passports are listed.

assistant
read_file(path = "packing-list.txt")
user
Warm jacket, hiking boots, rain gear, camera, chargers, medications.
assistant

No. Passports are not on the packing list.

✎ noteOne lookup, one answer. The agent knew what to look for and where.

Task B — we know what we are looking for, but not where it is.

Task B · Known information, unknown location
user

You have the following tools available for use:


  1. read_file( path )
  2. search_notes( query )

Task: Search our trip-planning materials and determine whether we ever discussed passports.

assistant
search_notes(query = "passport")
user
No matches in the meeting notes.
assistant
read_file(path = "packing-list.txt")
user
Warm jacket, hiking boots, rain gear, camera, chargers, medications.
assistant

No. Passports appear nowhere in the meeting notes or the packing list. We never discussed them.

✎ noteThe agent knew what it was hunting for, but had to search several places to find out whether it existed.

Task C — even what the agent should look for is part of the problem.

Task C · We don't yet know what matters
user

You have the following tools available for use:


  1. read_file( path )
  2. search_notes( query )

Task: Review our trip plans and identify anything important we have forgotten.

assistant
read_file(path = "itinerary.txt")
user
Fly Nashville to Molde via Amsterdam. Rental car at the airport. Day 3:
hike ending in Eresfjord, 40 km from the hotel.
assistant
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.")
user
OK.
assistant
search_notes(query = "passport OR license OR return transport")
user
No matches for any of these in the meeting notes.
assistant

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.

✎ noteEach observation changed what the agent decided to investigate next. It was not retrieving predetermined information — it was reasoning about what information it needs next.

The ladder of difficulty

Task Aknown information, known location — a direct lookup
Task Bknown information, unknown location — a search
Task Cunknown what matters — an investigation

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

what do I needdo I know what information the task requires
where is itdo I know where that information lives
how do I get itdo I know what action will produce it

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

providedalready in the prompt — "Here are three proposals. Compare their costs."
discoveredexists somewhere, the agent must find it — "How much did we pay this supplier last year?"
acquiredmust be produced through interaction — "Can this supplier deliver 500 units by Friday?"

In the acquired case the agent is not finding an existing answer. It is causing new information to be created.

Acquired · no document holds the answer
user

You have the following tools available for use:


  1. search_documents( query )
  2. send_email( to, message )

Task: Determine whether the supplier can deliver 500 units by Friday.

assistant
search_documents(query = "supplier delivery capacity 500 units")
user
No document answers this. Past orders show 200-unit deliveries.
assistant
send_email(to = "orders@supplier.com", message = "Can you deliver 500
units by this Friday?")
user
Reply received: "Yes — 500 units by Friday is possible with two-day
notice."
assistant

Yes. No record answered the question, so I asked the supplier directly. They confirmed 500 units by Friday with two-day notice.

✎ noteThe answer did not exist until the agent's action created it. The email produced a new observation.

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.

The downtown store
user

You have the following tools available for use:


  1. query_sales( filter )
  2. search_records( query )

Task: Figure out why sales at our downtown store fell sharply last month.

assistant
query_sales(filter = "downtown, by day of week")
user
The decline happened primarily on weekends.
assistant
think(thought = "Weekends — was staffing different on weekends?")
user
OK.
assistant
search_records(query = "weekend staffing changes downtown")
user
No major staffing changes last month.
assistant
query_sales(filter = "downtown, weekends, by product category and hour")
user
Most of the decline came from lunchtime purchases.
assistant
think(thought = "Lunchtime, weekends. Something outside the store —
nearby events, transportation, competing businesses?")
user
OK.
assistant
search_records(query = "downtown area construction closures last month")
user
The parking garage beside the store was closed for construction.
assistant

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.

✎ noteFive acquisition steps, and none of them were planned in advance. Each observation determined the next search.

Acquisition depth

acquisition depththe number of sequential acquisition steps a task requires

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

epistemic actionexists to learn — "Do you have 40 rooms available on August 26?"
consequential actionexists to change the world — "Reserve those 40 rooms."

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.

Reading 500 more reviewslittle new information about where the delay occurs
Timing ten lunch orders stage by stagedirectly shows where the minutes go

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.