Topic 3 of 5 · 4 min read
Signals that an agent should look it up
Goal: Read an agent transcript and mark the points where it should have searched instead of guessing.
An agent should search the moment it is about to rely on a name, version, number or fact it has not seen in this session. Models complete patterns fluently, so a guess reads exactly like knowledge. The fix is to make "have I seen this?" a habit, in the prompt and in your review.
Check yourself · 1 of 3
An agent writes a call to billing.applyCredit(), a function it never opened in this session. What should it have done?
Why it matters
A model's training data has a cutoff and misses your private code. It will still write a plausible function call, flag or config key. The result compiles in the mind and fails at run time, or worse, runs and does the wrong thing. Retrieval beats recall for anything that is yours, new or exact.
The four signals
- Unknown name. A function, table, env var or ticket the agent has not opened. If it did not read it this session, it is a guess.
- Version-specific API. Library behaviour changes between releases. Claude, ChatGPT, Gemini and Copilot can all describe a method that was renamed or removed. Check the installed version and its docs.
- Stale assumption. Something true earlier in the session, such as file contents before an edit, a branch name, or a test result, may no longer hold. Re-read.
- Low confidence. Hedging words ("probably", "I believe", "should be") are a cue. So is an answer with an exact value, such as a port or a price, that nothing in context supplied.
Teaching it to the agent
Put the rule in the instructions, in concrete terms:
Before calling a function, class or config key you have not opened in this session, grep for it.
Before using a third-party API, check the installed version in package.json and read its docs.
After editing a file, re-read the changed region before building on it.
If you are unsure, say what you are unsure about and search; do not fill the gap.
Before and after
Weak transcript:
user: Add retry to the payment call.
agent: Using the client's built-in retry option: client.charge(data, { retries: 3 })
The agent never opened the client. In this project the option is maxAttempts, set on the client, not per call.
Better:
agent: [grep "class PaymentClient"] [read src/payments/client.ts:1-80]
agent: Retry is configured with maxAttempts in the constructor. I'll set it there.
What goes wrong
- Searching everything. If the agent looks up facts it already has in context, it wastes turns. The signal is "not seen", not "not sure of anything".
- Searching once, then drifting. The agent verifies at the start and guesses for the next 20 steps.
- Ignoring empty results. A grep that finds nothing means the name may be wrong; the agent should say so, not invent a match.
Examples
Marking a transcript
agent: I'll read the config from settings.cacheTtl.
agent: [edits src/cache.ts]
agent: Now the test should pass, the TTL is 300 seconds.
Two missed lookups. settings.cacheTtl was never opened or grepped (unknown name). The 300 came from nowhere in context (unsupported number). A good run greps for cacheTtl, reads the value and runs the test.
A version check
The agent writes app.use(bodyParser.json()) for a project on a newer Express where that is built in. One read of package.json and the framework docs would have shown the current form. The trigger was a version-specific API.
Key points
- Search before relying on a name, version, number or fact that has not appeared in this session.
- Unknown names, version-specific APIs, stale assumptions and hedged answers are the four main triggers.
- Fluent output is not evidence; a plausible method name can still be wrong for your installed version.
- Write the triggers into the agent's instructions as concrete rules, not as a general plea to be careful.
- An empty search result is information: the name may not exist, and the agent should report that.
Common mistakes
- Letting the agent answer with exact values (ports, limits, prices) that nothing in context provided.
- Trusting an earlier read of a file after the file has been edited.
- Writing a vague rule like "be careful" instead of naming the triggers.
- Treating a grep with no results as permission to invent the missing name.
Check yourself · 2 of 3
Which agent sentence is the strongest cue to search before continuing?
Check yourself · 3 of 3
An agent edits a file, then ten steps later builds on the original contents it read earlier. Which trigger is this?
Practice items, not counted towards your mastery.
Start here
- Effective context engineering for AI agents (Anthropic) (opens in a new tab)ArticleFree
Defines just-in-time context, light references and the hybrid of pre-loaded data plus agent exploration.
- Context engineering for agents (LangChain) (opens in a new tab)ArticleFree
A vendor-neutral map of writing, selecting, compressing and isolating context for agents.
- Best practices for Claude Code (Claude Code docs) (opens in a new tab)DocsFree
Practical advice on instruction files, exploring code and verifying work with a coding agent.