← Table of Contents · Page 680 of 868
PROJECT TWO - ADDING CONTEXT MANAGEMENT
Part 7 of 11
EXAMPLES
Example 1: A context builder keeps five messages and the flagged ones.
A learner extends Project One so that, instead of dumping the entire raw conversation into every call, a function selects the most recent five messages plus any message flagged as important.
This is exactly what build_context does, and the DECISION lines are the flagged messages.
Example 2: A compaction trigger with a recall check.
The learner adds a rule that summarizes the oldest half of the conversation once the token total crosses a threshold.
Then the learner checks that a fact from the summarized part, such as the decision for resume_01.txt, can still be found afterward.
In the lab you can test this by lowering COMPACTION_THRESHOLD to a very small number and confirming the summary message still lists every DECISION line.
Example 3: External notes and a simulated restart.
The learner's agent writes a running scratchpad during a multi-step task, then the learner deliberately stops it halfway and starts it again.
If the agent reads the scratchpad and carries on correctly, the notes are doing their job.
The progress_notes.md file in the lab is that scratchpad.
Example 4: Measuring the effect.
A learner runs the same ten-task benchmark before and after adding context management and records that the average cost per task dropped by about forty percent with no measurable drop in success rate.
That is a good result because it names a number, uses the same tasks both times, and checks quality as well as cost.
In the lab, the compare command does the same thing for the twenty-five resumes.
Advertisement
Read Aloud:
0:00 / 0:00