← Table of Contents · Page 223 of 868
COMPACTION AND SUMMARIZATION
Part 7 of 10
PRACTICE LAB CONNECTION
Add compaction to the Resume Review Agent lab in Chapter 66, where it is an explicitly required deliverable.
Implement a function that checks the token count before every model call, fires when the count crosses your threshold, keeps the most recent messages, and replaces older ones with a structured summary.
Include a Decisions section in your template.
Then test the prompts below against your compaction logic and its summaries.
A good test is to process a long batch of resumes, force a compaction midway, and then ask the agent about a decision it made before the compaction.
If it can answer correctly, your summary preserved what mattered.
Advertisement
Read Aloud:
0:00 / 0:00