85 agentic tools audited for security incidents · Talk to the lab →
MotionticBook a call
Glossary

Trimming vs summarization: managing an agent's conversation history

Trimming and summarization are the two standard ways to keep an agent's conversation history inside its context window: trimming drops all but the most recent turns, while summarization compresses older turns into a shorter written summary.

Every multi-turn agent eventually has more history than it should send. OpenAI's Agents SDK cookbook on short-term memory with sessions names the two basic responses and lays out their trade-offs. A turn, in its definition, is one user message and everything until the next user message, including assistant replies and tool calls.

Both are lossy. Anthropic's Managed Agents post (2026-04-08) calls trimming and compaction irreversible decisions about what to keep, which is why both should be applied to the prompt while the full history stays in a durable session log.

Trimming

  • How it works

    Keep the last N turns and drop the rest. OpenAI's Agents SDK also supports a retrieval limit on sessions, so only the N most recent items are loaded into each run.

  • Strengths

    Deterministic and simple, no extra model call and no added latency, recent work stays word for word, and there is no summary drift.

  • Weaknesses

    Long-range context disappears abruptly, so an early constraint or ID can vanish. A single recent turn with a large tool payload can still spike token use.

Summarization

  • How it works

    Older turns are replaced with a summary, and the last few turns are kept verbatim. The cookbook inserts the summary as a synthetic exchange so the model reads it as conversation history.

  • Strengths

    Long-range memory survives in compact form, long sessions feel continuous, and one summary can replace many turns.

  • Weaknesses

    The summary can drop or misweight a constraint, each refresh adds latency and cost, and a wrong fact in a summary can poison every later turn. Summary prompts and outputs also need logging to debug.

Writing the summary prompt

The cookbook's example summary is capped at about 200 words under fixed headings, such as the reported issue, steps tried, identifiers, timeline, current status and next step. It checks for contradictions, lets the latest update win, marks uncertain facts as unverified, quotes error codes exactly and records what has been superseded.

Google's context-aware framework post (2025-12-04) applies the same idea at framework level: an asynchronous summariser compacts older events over a sliding window with configurable overlap, and writes the summary back to the session as a new event.

Related techniques

Compaction is summarization run by the platform at a token threshold. Context editing is a targeted form of trimming that clears specific items, such as old tool results, and leaves the rest of the conversation intact.

How Motiontic's engineers apply it

Motiontic's engineers pick by what the agent must remember. Short, independent tasks get trimming. Long threads where early decisions matter get summarization with a fixed-heading prompt, and exact values such as IDs and amounts are kept in structured state so neither tactic can lose them.

Trimming compared with summarization

Trimming compared with summarization
TrimmingSummarization
What happens to old turnsDroppedCompressed into a summary
Extra model callsNoneOne per summary refresh
Recent turnsVerbatimVerbatim for the last few
Long-range memoryLost abruptlyKept in compact form
Main riskForgotten constraints and IDsSummary drift and context poisoning
FitsIndependent tasks, ops automations, API actionsLong threads: planning, coaching, analysis, policy Q&A

Common questions

What is conversation trimming in AI agents?

Trimming keeps only the most recent turns of a conversation in the prompt and drops older ones. It is simple and deterministic, but anything said before the cut-off is no longer visible to the model.

When should an agent summarize instead of trim?

When earlier decisions, constraints or identifiers must stay in play across a long thread. For short, independent tasks where recent steps matter most, trimming is cheaper and more predictable.

Is summarization the same as compaction?

Compaction is a form of summarization, usually run by the platform when context crosses a threshold. The trade-offs are the same: continuity in exchange for possible loss of detail.

Running agents that have to hold up?

Describe the agent, the systems it touches and what it must never get wrong. The first call is with a lab engineer, who will say plainly whether it is ready for production, and whether Motiontic is the right team.