When agent sessions generate millions of tokens of conversation history, compression becomes mandatory. The naive approach is aggressive compression to minimize tokens per request. The correct optimization target is tokens per task: total tokens consumed to complete a task, including re-fetching costs when compression loses critical information.
Context compression trades token savings against information loss. Three production-ready approaches exist:
The critical insight: structure forces preservation. Dedicated sections act as checklists that the summarizer must populate, preventing silent information drift.
Этот навык следует использовать, когда пользователь просит «сжать контекст», «обобщить историю разговоров», «реализовать уплотнение», «уменьшить использование токенов» или упоминает сжатие контекста, структурированное суммирование, оптимизацию токенов для каждой задачи или длительные сеансы агента, превышающие ограничения контекста. Источник: guanyang/antigravity-skills.