Skip to content

fix(plugins): prompt Codex checkpoints after compaction#1142

Open
phernandez wants to merge 5 commits into
mainfrom
fix/codex-checkpoint-session-start
Open

fix(plugins): prompt Codex checkpoints after compaction#1142
phernandez wants to merge 5 commits into
mainfrom
fix/codex-checkpoint-session-start

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

PR #1138 introduced a PreCompact-to-Stop request handshake so Codex could author durable
checkpoints instead of promoting lifecycle telemetry into graph notes. A real reinstall showed
that the request files accumulated while subsequent compactions produced no checkpoint notes:
the Stop continuation is not the reliable post-compaction entrypoint we assumed.

Codex does provide a deterministic post-compaction entrypoint: SessionStart runs again with the
compact trigger and the resumed agent has the compacted working context needed to write a useful
handoff. This PR moves checkpoint prompting to that lifecycle event and removes the private
coordination machinery.

What Changed

  • Prefix the Codex SessionStart context with a request to run codex:bm-checkpoint when the
    trigger is compact and a primary Basic Memory project is configured.
  • Keep Codex PreCompact limited to lifecycle-envelope capture; it no longer creates a checkpoint
    request file.
  • Remove the Codex Stop hook, launcher, CLI verb, request persistence module, tests, release
    wiring, and status counter.
  • Make hook reinstall remove only Basic Memory's retired Stop entry while preserving user-owned
    hooks in the same event.
  • Update plugin documentation, status/checkpoint skills, and package validation around the
    SessionStart flow.
  • Pin the surviving SessionStart and PreCompact shims to the immutable implementation commit
    a2a3b1fd8aca21123c464064fff8feb7040d2af1.

Implementation Details

Codex ignores PreCompact stdout, so PreCompact cannot directly ask the model to write a note.
After compaction, _session_start() recognizes the Codex compact trigger and prefixes the normal
Basic Memory orientation brief with the deliberate checkpoint instruction. The prompt is retained
even when the graph is temporarily unreachable, and sessionProfile only determines whether the
checkpoint skill writes a codex_session or coding_session note.

There is no background or synthetic-note fallback. The resumed agent remains responsible for
writing one useful, evidence-backed checkpoint from its compacted context. Lifecycle envelopes
remain private local trace and do not become graph notes.

The installer keeps the retired stop command in its ownership matcher solely so upgrades can
remove Basic Memory's old Stop hook without deleting unrelated user hooks.

Testing

Automated

  • git diff --check: passed.
  • just fast-check: passed; type checking reported nine existing Python 3.14 asyncio deprecation
    warnings.
  • BASIC_MEMORY_ENV=test LOGFIRE_IGNORE_NO_CONFIG=1 uv run pytest -q --no-cov tests/cli/test_hook_command.py tests/test_codex_plugin_package.py plugins/codex/hooks: 119 passed.
  • just package-check: passed across the Claude Code, Codex, shared-skill, Hermes, and OpenClaw
    package gates; Hermes reported 257 passed / 12 opt-in integration skips and OpenClaw reported
    226 passed.
  • BASIC_MEMORY_ENV=test LOGFIRE_IGNORE_NO_CONFIG=1 just doctor: passed.

Manual

  • Confirmed both surviving PEP 723 hook shims resolve the immutable implementation commit that
    contains the new SessionStart behavior.
  • Confirmed the branch contains two signed-off commits and is based on current origin/main.

Risks / Follow-ups

  • The behavior depends on Codex continuing to emit SessionStart with trigger = "compact"; the
    package tests cover that contract and distinguish it from ordinary startup.
  • Existing private checkpoint-request files from older installs are left inert on disk rather
    than deleting user-local data during upgrade.
  • A full marketplace reinstall/restart/compaction smoke should be performed after merge so the
    installed cache can be proven against the merged package.

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: 5aa5728829

ℹ️ 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>

@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: 53136dd728

ℹ️ 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/hooks/session_start.py Outdated
Signed-off-by: phernandez <paul@basicmachines.co>
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