Lesson 60.1 · 1 of 4 · 4 min read · Reviewed 24 Nov 2026
Progressive summarization
By the end, you can
- Summarise a conversation progressively as it grows.
- Choose what a running summary keeps.
Long chats outgrow the window. Progressive summarisation keeps them going.
The pattern
[running summary of turns 1-40]
[turns 41-50 in full]
[new user message]
Every N turns, or when the context passes a threshold, fold the oldest full turns into the summary.
What the summary must keep
- Goal and current status.
- Decisions made and why.
- Facts established: ids, amounts, dates, names, verbatim.
- Commitments: “We promised a callback by Friday.”
- Open questions.
What can go
Greetings, thanks, repeated confirmations, dead ends that are fully resolved.
Watch for drift
Each summary of a summary can lose detail or add errors. Keep critical facts in a separate structured block that’s copied forward unchanged (60.4).
Key points
- Progressive summarisation keeps recent turns in full and replaces older turns with a running summary.
- The summary should keep goals, decisions, facts, open questions and commitments.
- Summaries lose detail, so keep exact values such as ids, amounts and dates verbatim.
Write a running summary with verbatim facts
Fold older turns of a support chat into a running summary that keeps goals, decisions, commitments and exact ids, and check nothing critical was paraphrased.
You will have: A fold function, the summary after the chat, and a check that every id and amount from the chat appears in it unchanged.
Steps
- Read the 24 sample turns: some carry tags such as GOAL, DECISION, PROMISE or an order id.
- Write fold(summary, turns) that keeps tagged lines and any line containing an id or amount, and drops small talk.
- Every 8 turns, fold all but the newest 4 turns into the summary.
- Print the final summary and the recent turns.
- Use a regex to collect ids and amounts from the full chat and check each appears verbatim in summary plus recent turns.
Done when
- The summary contains ORD-48213 and 64.50 exactly.
- The callback promise survives.
- Greetings and thanks are not in the summary.
Open in the Playground No API key needed.
Starter code (Python)
import re
TURNS = ["user: hi there", "agent: hello, how can I help?", "user: GOAL: my parcel ORD-48213 arrived damaged",
"agent: sorry to hear that", "user: thanks", "agent: DECISION: refund 64.50 to the original card",
"user: great, cheers", "agent: PROMISE: confirmation email within 1 hour"] + \
["user: small talk %d" % i if i % 2 else "agent: ok, noted %d" % i for i in range(16)]
ID_OR_AMOUNT = re.compile(r"ORD-\d+|\d+\.\d{2}")
def fold(summary, turns):
# TODO: keep lines with GOAL, DECISION, PROMISE or an id or amount; drop the rest
return summary
summary, recent = [], []
for i, t in enumerate(TURNS, 1):
recent.append(t)
if i % 8 == 0:
summary, recent = fold(summary, recent[:-4]), recent[-4:]
print("summary:", summary)
print("recent:", recent)
Show a solution
import re
TURNS = ["user: hi there", "agent: hello, how can I help?", "user: GOAL: my parcel ORD-48213 arrived damaged",
"agent: sorry to hear that", "user: thanks", "agent: DECISION: refund 64.50 to the original card",
"user: great, cheers", "agent: PROMISE: confirmation email within 1 hour"] + \
["user: small talk %d" % i if i % 2 else "agent: ok, noted %d" % i for i in range(16)]
ID_OR_AMOUNT = re.compile(r"ORD-\d+|\d+\.\d{2}")
TAGS = ("GOAL:", "DECISION:", "PROMISE:", "OPEN:")
def fold(summary, turns):
keep = [t.split(": ", 1)[1] for t in turns if any(tag in t for tag in TAGS) or ID_OR_AMOUNT.search(t)]
return summary + keep
summary, recent = [], []
for i, t in enumerate(TURNS, 1):
recent.append(t)
if i % 8 == 0:
summary, recent = fold(summary, recent[:-4]), recent[-4:]
print("summary:", summary)
print("recent:", recent)
kept = " ".join(summary + recent)
needed = set(ID_OR_AMOUNT.findall(" ".join(TURNS)))
print("verbatim ids and amounts:", sorted(needed), all(x in kept for x in needed))
print("small talk in summary:", any("thanks" in s or "hi there" in s for s in summary))