Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How to Tell What Claude Code and Codex Forget When They Compact a Session

Описание и применение

Кодовые агенты теряют данные, которые только читали, при сжатии сессии. Чтобы сохранить критические факты, их нужно сохранять на диск и явно указывать в команде /compact.

Задача

Coding agents lose in‑memory facts when they compact a session, causing missing data and repeated work.

Результат

By explicitly saving non‑regenerable facts and configuring compaction prompts, agents retain critical information, reducing repeated work and avoiding silent data loss.

Рабочий процесс

  • 1. Identify facts that cannot be regenerated (e.g., test failures, logs).
  • 2. Before compaction, write those facts to a persistent notes file or include them in a /compact command with a keep list.
  • 3. Use a /compact prompt that instructs the agent to keep exact error strings, ids, file paths, and test names.
  • 4. Configure Codex’s compact_prompt in ~/.codex/config.toml to enforce the keep list.
  • 5. Move rules that must survive compaction into the root rules file or a dedicated Compact Instructions section in CLAUDE.md.
  • 6. Add a SessionStart hook that runs after compaction to restore state (e.g., git status and notes file).
  • 7. In custom agents, keep the file list as data and re‑inject it after summarization.
  • 8. Audit a real session to verify retention of critical facts.

Доказательства

A compacted agent keeps your instructions and its own edits, but loses most of what it only read.

Источник

In my test session, 78,642 tokens became 2,632. That is 97% gone in about twenty seconds, and the session looks healthy afterward.

Источник

The summary kept what mattered to the work so far. In an earlier run, the last task counted timeouts over 5000. Of six values I probed, only the two timeouts over 5000 survived.

Источник

  • Дата записи: 2026-11-01T21:43:51.947Z