Why it matters

Modular summary shapes clean architecture. Understanding enables compression as pluggable service.

Advertisement

The architecture

Summary agent: LlmAgent with summarization prompt.

Called when context nears limit.

Summary agent patternMain agenthandles queriesSummary agentcompresses on demandContinue with summaryin contextSame base model or cheaper; summary quality matters
Summary agent flow.
Advertisement

How it works end to end

Trigger: token count exceeds threshold.

Summary prompt: 'Summarize following, preserving key facts + decisions.'

Output: concise summary to replace older turns.

Test: verify summary preserves needed info.