Short-Term Memory — Keeping the Working Context Lean
Planning a three-city trip, Tripmate makes 30 tool calls. Each train search returns a big block of text, and by call 25 the context is nearly full, every call is slow and expensive, and the model starts overlooking details. Short-term memory is the working context of one task, and it needs managing like a desk that keeps filling up.
The rule
Keep the goal and the decisions; shrink the raw material.
Short-term memory is everything carried from turn to turn inside the context window: the instructions, the conversation, the plan, and tool results. Three techniques keep it useful:
- Trimming — cut tool results down to what matters before storing them. Fifteen trains with every stop become the three candidates, with times and fares.
- Sliding window — keep the most recent turns in full and drop older ones. Simple, but anything important from early on must be saved separately first.
- Summarization (compression) — replace a long stretch of old turns with a short summary written by the model: decisions made, facts learned, open questions.
What must survive every cut:
- the user's goal and constraints (dates, budget, "vegetarian"),
- decisions already made ("Pune → Jaipur leg: booked the Friday sleeper"),
- what is still open ("Jaipur → Udaipur leg: not yet searched").
A healthy working context often has three layers:
[pinned] Goal: Pune → Jaipur → Udaipur → Pune, 15–22 Oct, ₹8,000 total, vegetarian
[summary] Leg 1 booked (Friday sleeper, ₹1,180). Leg 2 options: 2 trains shortlisted.
[recent] last 6 turns in full