← Table of Contents · Page 212 of 868

CONTEXT CONSTRUCTION (THE CONTEXT BUILDER)

Part 8 of 12

EXAMPLES Example 1: A system reminder. Imagine a financial helper agent whose opening instructions include "Never reveal API keys in your response." An API key is a secret code that lets software prove its identity to another service, a bit like a password for programs. During a long session, the agent reads many configuration files, some of which contain keys. To keep the rule fresh, the harness re-inserts a short note every five turns and also immediately after any step that reads a configuration file. The note says, "Remember: never reveal API keys in your response." In testing, the agent that receives these reminders stays compliant over hundreds of turns, while the agent without reminders occasionally slips. The reminder costs a dozen tokens, which is a small price for the protection. Example 2: Prompt composition. Consider a team that runs three different agents, one for code review, one for documentation, and one for support. They create reusable blocks stored as separate small text files. The core identity block for each agent is different. The shared safety block is the same for all three. A current project rules block is loaded from the project's own conventions file. A date block is generated automatically. At the start of every run, the builder joins the blocks fresh. Later, the team discovers that a safety rule needs updating. They edit one file, and all three agents are updated at once, with no copy-and-paste mistakes. Example 3: Selecting context for a coding agent. A coding agent is asked to fix a failing test. The project has 800 files. The builder includes the failing test's error message, the three files edited most recently, and the single file named in the error. It leaves out a long configuration file for the deployment system, which has nothing to do with the bug. When the agent later says it needs to see how logins are checked, the builder uses a search to find the relevant file and adds it, while shrinking an older file that is no longer needed. The window stays small, and every item in it earns its place. Example 4: Ordering for best results. A resume review agent must follow a strict rule: it may only state skills that appear in the resume text. The builder places the rule at the very top of the context in the standing rules block. Then come the job posting and the resume text in the middle, each clearly labeled. Finally, near the end, directly before the question, the builder repeats the rule in one sentence and then states the task: "Compare this resume to the posting and list matching skills, using only skills that appear in the resume." Because the rule appears at both the beginning and the end, it is far less likely to be ignored than if it were buried in the middle of a long block of resume text.
Advertisement
Read Aloud:
0:00 / 0:00