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
- 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]
- Configure the documented
context_managementcompaction strategy, threshold, and summary instructions for the Managed Agent. [source07] - 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
- Anthropic API key and a long-running test conversation; context editing is API/model dependent.
Permissions
- Use approved test or anonymized data only; scope credentials to each workflow, and require explicit approval for external writes.
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
- 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