Skip to content

Interview question · Context Engineering & Caching

Clearing tool results, compacting the history, writing notes: when does each one fit?

They are not three names for one idea. They lose different things, cost the cache differently and fail differently, and a good answer picks by what the run can afford to lose.

mediumEssentialNewUpdated Nov 2026

TL;DR: Order them by what they lose. Clearing drops the bulk of tool results the agent has already used and keeps the record of each call, so it is nearly lossless and runs first. Notes move what must outlast the transcript (decisions with reasons, progress, current facts, active handles) into a small block the harness renders every turn, so they run continuously. Compaction rewrites the conversation into a summary and loses whatever the summary omits, so it runs rarely, at a boundary, under a contract and a test.

How to approach it

Name the three precisely before comparing them, because candidates often use "compaction" for all of them. Then compare on the same three axes for each: what is lost, what it does to the prompt cache, and how it fails. Finish with the order you apply them in and the signal that moves you to the next one.

A strong answer

ClearingNotesCompaction
What changesUsed results become placeholders; calls stayA small structured block is kept currentEarlier turns replaced by a summary
What is lostThe bulk of results, recoverable by calling againNothing, if written wellWhatever the summary leaves out, unrecoverable
Cache costMiss from the first cleared result, once per batchNone if rendered at the endMiss for the compacted region
Typical failureClearing a result the model is still usingStale or missing entries; model-written goal driftA dropped identifier, constraint or failed approach
WhenFirst threshold, oftenEvery turnLater threshold or a finished subtask

Which fits which run.

  • A coding agent that reads many files and test logs. Almost all growth is tool output. Clearing alone keeps it well under budget for a long time; notes record decisions ("export is server-side because client export broke at 50k rows") so clearing the log that taught the lesson costs nothing.
  • A support conversation that runs for hours. Growth is mostly what the customer said, which clearing cannot touch. Notes carry the case facts as they are confirmed; compaction eventually runs at a natural boundary, such as a resolved issue, under a contract that keeps every identifier and commitment.
  • A research agent reading forty pages. Neither is the main tool: isolate the reading in subagents that return findings, so the pages never enter the parent's context.

The order, and the signal to move on. Clear at a first threshold. If the context is still over budget after clearing because the conversation itself is long, compact at a second, higher threshold or at the next subtask boundary. Notes are not a step in the sequence; they run all the time, and they are what makes the other two safe.

What interviewers probe next

"Why keep the tool call when you clear the result?" Without it the model has no record that it read the file, and it reads it again or assumes the information does not exist. The placeholder says what was there and how to get it back.

"Who writes the notes, the model or the harness?" Both, for different sections. The harness owns the goal and constraints, copied from run state so nothing can drift them; the model writes decisions, progress and facts through a notes tool.

"Can compaction be done by a smaller, cheaper model?" Yes, if it passes the same tests. The risk is not fluency but omission, so measure identifier and decision retention on replayed traces before switching.

What if?

What if · interview follow-ups

Hold your answer as the constraints change

Your agent clears used tool results at 40% of the window and compacts the conversation at 70%.

  1. Start here

    What if, after clearing, the agent keeps calling the same tool to reread results it already cleared?

How it's scored

Weak: Treats all three as summarisation, or proposes summarising every turn.

Hire: Distinguishes them by what they lose, applies clearing before compaction, and keeps decisions in notes.

Strong Hire: Compares all three on loss, cache cost and failure mode, matches them to the shape of each run (tool-heavy, conversation-heavy, exploration-heavy), gives the harness ownership of fixed note sections, and names the metrics that show a reduction went wrong.

Common mistakes

  • Compacting first, the lossiest step, when most of the context is clearable tool output.
  • Deleting tool calls along with their results.
  • Letting the model rewrite the goal and constraints in its own notes.
  • Forgetting that each reduction breaks the cache, and running them every turn.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 6, and the site remembers where you stopped in each one.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in raises your free answers from 5 to 6 per topic, adds an applied lesson in every topic and easy practice tests, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

Nobody has commented. Post a correction or another way to answer.