Agent Wealth HubFree public resources
中文 EN العربية

Back to catalog / Agent workflows

Compact context automatically during long research sessions

Configure Managed Agents to summarize older turns near the context threshold so the agent can continue incorporating new evidence.

Goal

Build a long-running research workflow that preserves the active question and key findings after compaction.

Steps

  1. Run an uncompacted baseline for the same research task; note when the context window approaches its limit and whether later turns lose early evidence. [source07]
  2. Configure the documented context_management compaction strategy, threshold, and summary instructions for the Managed Agent. [source07]
  3. Repeat the task and inspect compaction events and summary text; confirm new evidence is incorporated, key sources remain, and the summary is not treated as a full transcript. [source07]

How to verify

Tests show automatic compaction occurs near the configured threshold and later answers retain key evidence while recognizing summary loss.

Troubleshooting

If compaction does not trigger or drops critical details, check model and beta API support, lower the threshold, or reduce input; a summary is not a verbatim audit log.

Permissions

Prerequisites

Permissions

Limitations

Model output may be incomplete or wrong; API and beta behavior can change, so verify against the pinned source and current service behavior.

Pinned upstream source

https://github.com/anthropics/anthropic-cookbook/blob/9c1e493ddd2b82df399d2a61b9c806c539e18be6/tool_use/automatic-context-compaction.ipynb

Repository
anthropics/anthropic-cookbook
File path
tool_use/automatic-context-compaction.ipynb
Pinned commit
9c1e493ddd2b82df399d2a61b9c806c539e18be6
Source checked
2026-10-14 · Reviewed against the pinned upstream source

Repository metrics

These values describe the upstream repository, not popularity or likes for an individual skill or playbook.

Stars
Not collected
Forks
Not collected
Observed at
Not collected

No metrics snapshot is available yet.

License: MIT

Main topic

Turn ecommerce campaign materials into a reviewable weekly brief

Related resources