anthropics / anthropics/claude-cookbooks
[PROPOSAL] Cookbook: Surviving the context limit with a deterministic handoff
- Lingua principale
- Jupyter Notebook
- Stelle
- 52.7k
- Fork
- 6.3k
- Merge medio
- 25m
- PR unite (30g)
- 6
Descrizione
A long-running agent eventually hits its context limit mid-task. The usual outcomes are a summary that quietly drops the thing you cared about, or a hard stop. The pattern I have had the most success with is to treat the context boundary as a planned event and write a handoff the next session can resume from mechanically, rather than re-reading and re-deriving state.
Two ideas make it reliable:
- A mechanical safety floor written unconditionally on every save, not just when the model remembers to. It is small and machine-shaped: current task, last decision and why, open threads, the exact file paths. Because it is written every time and never depends on the model choosing to, it is always at most one step stale.
- A richer model-written handoff on top of that floor for the parts that need judgment. If that one fails or gets truncated, the floor still carries the resume point, so a bad save degrades instead of losing the thread.
What the notebook would cover:
- A task deliberately larger than one context window, run two ways: a plain summarize-and-continue, and the floor-plus-handoff approach.
- A measure of resume quality: after the boundary, does the agent pick up the open thread or restart work it already did? Counting redone steps is a clean proxy.
- The structure of the floor: why one-fact-per-line and explicit file paths resume better than a prose recap, and why writing it on every step (not every N) is what keeps it from going stale.
- The honest cost: the floor is redundant most of the time since most steps do not rotate. The cookbook should show that overhead and argue it is cheap insurance for long runs, not free.
It runs on the messages API with a forced-truncation harness to simulate the boundary. I would target the agents section.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.