Skip to content

fix(plugins): author Codex checkpoints after compaction#1138

Merged
phernandez merged 5 commits into
mainfrom
fix/codex-agent-checkpoints
Jul 22, 2026
Merged

fix(plugins): author Codex checkpoints after compaction#1138
phernandez merged 5 commits into
mainfrom
fix/codex-agent-checkpoints

Conversation

@phernandez

@phernandez phernandez commented Jul 21, 2026

Copy link
Copy Markdown
Member

Why

Codex lifecycle capture was treating harness telemetry as durable knowledge. bm hook flush
projected sparse SessionStart/PreCompact envelopes into synthetic session and tool_ledger
notes, which produced low-value session garbage instead of useful handoffs.

The attempted automatic checkpoint path had a second mismatch: Codex ignores PreCompact
stdout, and the transcript adapter expected a Claude-shaped transcript rather than Codex
response_item events. Hooks could be enabled and visibly capture events without the active
agent ever authoring an actual checkpoint.

The Codex marketplace instructions also made it easy to sparse-checkout only plugins/codex,
which omits the repository marketplace manifest and causes the "marketplace root does not
contain a supported manifest" installation error.

What Changed

  • Keep lifecycle envelopes as owner-private local trace. basic-memory hook flush now archives
    valid envelopes locally and never writes knowledge-graph notes.
  • Add a Codex PreCompact-to-Stop handshake. PreCompact records a private checkpoint request;
    Stop blocks once and asks the active model to run codex:bm-checkpoint from its compacted
    working context.
  • Parse real Codex response_item.payload transcript records, including input_text and
    output_text, for checkpoint context.
  • Apply accumulated user/project redactKeys and redactPaths to every authored checkpoint
    field, failing closed instead of writing when the privacy gate cannot be satisfied.
  • Remove projected session / tool_ledger recall from the Claude and Codex skills and update
    hook status language to report archived trace and pending checkpoint requests.
  • Document the correct marketplace install shape: leave sparse paths empty, or include both
    .agents/plugins and plugins/codex; the marketplace manifest should not move.
  • Register and validate the new Codex Stop launcher and include it in release pinning.

Implementation Details

  • src/basic_memory/hooks/archive.py owns the trace-only flush path. Invalid envelopes remain
    pending for inspection; valid envelopes move into the private processed archive under the
    existing retention and locking rules.
  • src/basic_memory/hooks/checkpoint_requests.py stores one atomic, owner-only request per Codex
    session. The first Stop emits a decision: block response; the re-entrant Stop clears the
    request and continues when stop_hook_active is true, preventing a loop.
  • The active Codex model remains the checkpoint author. No nested agent or telemetry-to-note
    fallback manufactures memory from lifecycle payloads.
  • bm-checkpoint now scrubs title, directory, tags, frontmatter, body, repo/PR evidence, and
    embedded paths before write_note; required path fields use [REDACTED_PATH] instead of
    leaking or disappearing.
  • src/basic_memory/hooks/projector.py remains as a compatibility re-export while the graph
    projection implementation is removed.
  • The three PEP 723 launchers are pinned to implementation commit
    f802a01ddd0d6eab5b83cc7c684619776b7df1db, which already contains the Stop command. Keeping
    the pin in a second commit avoids a wrapper/runtime circular dependency.

Testing

Automated

  • uv run pytest -q --no-cov tests/hooks tests/cli/test_hook_command.py tests/cli/test_coding_session_context.py plugins/codex/hooks tests/test_codex_plugin_package.py: 238 passed
  • just package-check-codex: passed against the final hook pin
  • just fast-check: passed
  • just package-check: passed across Claude Code, Codex, shared skills, Hermes, and OpenClaw packages
  • just doctor: passed
  • uv run python /Users/phernandez/.codex/skills/.system/plugin-creator/scripts/validate_plugin.py plugins/codex: passed
  • git diff --check: passed

Manual

  • Ran a local Codex lifecycle smoke flow: PreCompact created one checkpoint request, the first
    Stop returned the one-time block instruction, and the re-entrant Stop returned
    {"continue": true}.
  • Flushed seven existing and two synthetic envelopes. All moved to local archive; pending
    envelopes and checkpoint requests returned to zero.
  • Queried session and tool_ledger notes after the exact flush timestamp: 0 results, proving
    the flush path no longer promotes telemetry into the graph.

Risks / Follow-ups

  • The Stop hook can request an authored checkpoint but cannot guarantee that a model follows the
    skill correctly. The loop guard fails open, the privacy policy fails closed before writing,
    and neither path falls back to synthetic telemetry notes.
  • Existing synthetic session/tool-ledger notes are left untouched; deleting user data should be
    a separate, explicit cleanup operation.
  • Existing remote marketplace installs receive this behavior only after this change is merged
    and the plugin is refreshed in a new Codex thread.

Signed-off-by: phernandez <paul@basicmachines.co>
Signed-off-by: phernandez <paul@basicmachines.co>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54d5813ce0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/codex/skills/bm-checkpoint/SKILL.md
Signed-off-by: phernandez <paul@basicmachines.co>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2c9a3217c5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/basic_memory/cli/commands/hook.py
Signed-off-by: phernandez <paul@basicmachines.co>
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez
phernandez merged commit c28159d into main Jul 22, 2026
29 checks passed
@phernandez
phernandez deleted the fix/codex-agent-checkpoints branch July 22, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant