← Table of Contents · Page 209 of 868

CONTEXT CONSTRUCTION (THE CONTEXT BUILDER)

Part 5 of 12

SELECTING WHAT TO INCLUDE Now consider the hardest part of the builder's job, which is choosing what to put in. The harness has far more information available than can fit, so it must select. Let us consider three kinds of candidates. Past messages. A natural default is to include the most recent messages, because recent events are usually most relevant. A common technique is a sliding window, meaning the builder keeps the last N messages in full and drops or summarizes older ones. But recency alone is not enough, because some old messages are vital, such as the user's original request or a key decision. So good builders always keep a few anchors, meaning items that are never dropped, such as the original task and any explicit constraints the user stated. Files. If the agent is working with documents or code, the builder must pick which files to show. Reasonable rules include showing files the agent recently edited, files directly named in the error or the question, and files found by a search for the current topic. Unrelated files should stay out, even if they are in the same folder. Tool outputs. Tool outputs are the biggest source of bloat, as you learned. A good builder treats them with care. It may truncate long outputs, keeping the beginning and end. It may extract only the relevant parts, such as error lines. It may replace an old, large output with a short placeholder like "output of the file listing, 400 lines, removed; call the tool again if needed." It may keep a recent output in full for one or two steps and then shrink it. A useful test for every candidate item is to ask whether the next model call would produce a worse result if the item were missing. If the answer is no, the item probably does not belong. A second useful test is to ask whether the item could be fetched again cheaply if needed later. If yes, it is safe to drop it now and rely on fetching.
Advertisement
Read Aloud:
0:00 / 0:00