Skip to course content
Free LangChain course

LangChain for LLM Applications and RAG

Unit 08.00: What to carry between turns

A transcript grows every turn and buries the line that mattered. Extracted facts do not.

Fields, not history

Established facts go into named fields as the conversation produces them. The result is bounded rather than growing.

The code compares a transcript with an extracted record.

TURNS = [
    ("human", "why was I charged twice?"),
    ("ai", "I can see two charges on 14 June for 24.50 each."),
    ("human", "refund the second one"),
]

transcript = "\n".join(f"{role}: {text}" for role, text in TURNS)
extracted = {
    "account": "ACC-1187",
    "established": ["two charges on 2026-06-14", "24.50 each"],
    "request": "refund the second charge",
}

print(f"transcript : {len(transcript)} chars, grows every turn")
print(f"extracted  : {len(str(extracted))} chars, bounded")
print()
for k, v in extracted.items():
    print(f"  {k:12} {v}")

# "The assistant forgot" is nearly always a fact that was never extracted into a
# field, not a fact that was stored and lost. Extract as facts are established;
# the transcript buries the one line that mattered.

The extracted version is smaller and, more importantly, addressable. extracted["account"] is a lookup; finding the account number in a transcript is a search that gets harder every turn.

This also fixes the cost curve. A transcript is re-sent on every turn and grows every turn, so a long conversation becomes quadratic in tokens. Fields do not grow.

The mistake this prevents

The mistake is reaching for a memory feature. Memory systems store and retrieve what you give them, so a transcript stored verbatim is a transcript retrieved verbatim - the same burial problem with a retrieval step in front of it.

Takeaway

Extract established facts into named fields as they arise. Most reported memory failures are facts never extracted, and the transcript's growth is a cost problem as well as a retrieval one.