Skip to content

Pre-compaction notes-to-self: reserve buffer tokens so the agent writes durable state before context rollover (Codex pattern) #391

Description

@justrach

From the codex/opencode/grok-build orchestration research (2026-08-04): Codex reserves auto_compact_fallback_buffer_tokens and fires auto_compact_fallback_prompt right before context rollover — the agent writes notes-to-self BEFORE compaction instead of losing working state silently.

graff's fit is unusually good because the landing surface already exists: the #383 playbook substrate (deterministic curation, file-derived injection) and the trajectory archive. Proposal: when compaction is imminent, reserve a small token buffer and prompt one bounded turn: "write what your future self needs: current subgoal, key file:line anchors, decisions made, dead ends" — persist to a session-scoped scratch file (or playbook items with source=session) that re-injects post-compaction the same way HARD CONSTRAINTS does. The my-website post-mortem's context-degradation failure (221 calls, 66 over 128k, constraint recall decayed) is the evidence this class of loss is real.

Constraints: the note turn must be budgeted (it competes with the #390 narration reserve — one ledger should own both), never fires in workers (their contexts are disposable by design), and the note is state, not conversation — deterministic re-injection, no summarizer rewrites.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QbsV84fdmf39Bh2RF8LdPs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions