Keep a Codex Task on Track Through Compaction with Context Guard

Keep a Codex Task on Track Through Compaction with Context Guard

A practical Context Guard walkthrough: define requirements, compact a Codex task, recover the checklist, and verify the finished document.

3 min read730 words
Contents

A long Codex task can involve research, edits, tests, and several changes of direction. When the conversation is compacted, you still need the original constraints to apply to the result. You also need to know which requirements have actually been checked.

Context Guard keeps a private checklist of requirements and verification evidence alongside the task. This walkthrough shows how to define a concrete task, pause for compaction, recover the open requirements, and check the finished artifact against them.

The example is a practice exercise, not a transcript of a measured experiment.

1. Install and activate

Use a Codex surface that supports plugins and lifecycle Hooks. Follow the current installation guide for the supported Python and Codex versions and the commands for your platform.

Installation and Hook trust are separate steps. Start a fresh Codex task, open /hooks, review and trust the plugin's Hook definitions, then start another fresh task in a disposable practice workspace. Existing tasks may retain the version they started with.

In the Codex conversation, enter:

$context-guard

Use context-guard status to inspect the protected state. Enter these controls in the Codex conversation.

2. Give the task a concrete finish line

Ask Codex to prepare a small design document using this synthetic brief:

Create docs/design/checkout-v2.md for a practice checkout service.

Keep these decisions unchanged:
- The API is POST /checkout.
- The service validates the request before recording the order.
- The rollout date is 2026-10-01.

Use these sections: Context, Decisions, Validation, Open Questions.
Do not add infrastructure commitments.
Give each recommendation a source link or a "to verify" label.

First outline the document and list the acceptance checks.
Pause before writing the final file so I can run /compact.

The file path makes the expected result concrete. The fixed decisions and section names give you things to compare with the final document. The source-link rule makes unsupported recommendations visible.

Review the outline before proceeding. This pause is intentional: it leaves unfinished work available for the recovery exercise.

3. Compact, then inspect what survived

At the pause, run /compact in Codex. Once compaction finishes, enter:

context-guard status

Then ask:

Before continuing, restate the open requirements for
docs/design/checkout-v2.md, including the fixed decisions,
required sections, and evidence checks. Then write the file
and verify it against those requirements.

Compare the recovered requirements with the original brief. Check the API, operation order, date, four sections, infrastructure restriction, and recommendation rule. A status count alone cannot establish that the right details survived.

Context Guard's documented recovery behavior restores the open checklist after compaction or resume. Completed and historical work is tracked separately from the current work so earlier tasks do not automatically become new unfinished work.

4. Check the artifact and the evidence

Have Codex read the finished file and report what it verified. For this example, the readback should establish that the named file exists, contains the four required sections, and preserves the API, operation order, and date. Review recommendations for a source link or the explicit uncertainty label, and inspect whether the draft introduces an infrastructure commitment.

A successful formatting check only establishes formatting. It does not establish that the rollout date is correct or that a recommendation has support. Match each result to the requirement it actually checks, and review the cited sources yourself when their meaning matters.

Context Guard uses successful tool evidence associated with the requested result when checking completion. Its deterministic checks have limits: it cannot establish that an arbitrary design is sound or that every source supports an interpretation. Unclear evidence should remain unresolved rather than become a claim of success.

5. Recognize the ending

Normal successful paths are quiet. You do not need a special success receipt or private checkpoint command to finish an ordinary task.

If Context Guard reports that the task is not yet safely complete, ask which requirement still lacks evidence. Use context-guard diagnose for bounded diagnostic information, then address the missing check. A genuine pause for your input can end the turn while leaving the task unfinished.

For your next task, choose one concrete artifact and write down its acceptance checks before work starts. After compaction, inspect the recovered requirements; before accepting completion, inspect the artifact and the evidence. Context Guard helps carry that workflow across a long conversation, while tests and human review remain essential.

Continue reading

All posts