Context management notes
824 B - 元のファイルを表示
Prompt caching
- The cache matches the request from the start: tools, then system, then messages.
- Any changed byte invalidates everything after it. A timestamp in the system prompt means a cache miss on every request.
- Cache reads cost a small fraction of normal input tokens; cache writes cost a bit more.
Long conversations
- Compaction: the API summarizes earlier turns when the request gets large, and returns a compaction block that must be sent back unchanged.
- Context editing: clears old tool results (or thinking) from what the model sees. It does not summarize.
- Memory: files the agent keeps across conversations. Not the same as the session history.
Questions to review
- When is context editing better than compaction?
- Why must the history be append-only?