This document defines the temporary cross-session continuity layer in codex-auto-memory.
Durable auto memory is optimized for stable, future-useful knowledge. It is not a complete answer to the problem of resuming unfinished work after:
- context compaction
- a fresh conversation window
- a paused work session
- a worktree switch
Community setups for local coding agents often solve this by introducing a separate temporary session file. The most useful pattern observed in community practice is to preserve four categories:
- what is confirmed working
- what has been tried and failed
- what has not yet been tried
- what remains incomplete or should happen next
In practice, a fifth category is also useful for continuity: files modified, key decisions made, and environment prerequisites that aid the next conversation without fitting cleanly into the four primary categories. The implementation stores this as filesDecisionsEnvironment and includes it in the compiled startup block.
codex-auto-memory adopts that idea as a separate companion layer, not as part of durable auto memory.
Session continuity is:
- temporary
- resume-oriented
- Markdown-first
- editable and auditable
- optional
Session continuity is not:
- durable auto memory
- a full transcript archive
- a cloud sync feature
- a replacement for
MEMORY.md
Use durable auto memory for:
- stable commands
- lasting architecture decisions
- recurring debugging insights
- long-lived preferences
Use session continuity for:
- what is currently in progress
- what failed in this working thread
- what the next conversation should continue
- worktree-local environment notes
If information becomes stable and future-useful beyond the current thread, it should move into durable memory rather than stay in session continuity.
codex-auto-memory uses two continuity layers:
Canonical shared state lives in the companion store:
~/.codex-auto-memory/projects/<project-id>/continuity/project/active.md
This is the only continuity layer that is reliably shared across git worktrees.
Project-local state lives in a hidden directory inside the current worktree.
Codex-first default:
<project-root>/.codex-auto-memory/sessions/active.md
Legacy tmp-style adapter mode:
<project-root>/.claude/sessions/<date>-<short-id>-session.tmp
The local layer is intended for worktree-specific or personally local state.
The continuity summarizer now produces two summaries per save:
project: the shared repository continuity layerprojectLocal: the current worktree's local continuity layer
Each layer uses the same sections:
goalconfirmedWorkingtriedAndFailednotYetTriedincompleteNextfilesDecisionsEnvironment
Default assignment rules:
confirmedWorkingandtriedAndFailedgo to the shared project layer unless they are explicitly local-only- exact next steps go to the local layer by default
- file modification notes go to the local layer by default
- project-wide prerequisites and decisions stay in the shared layer
- file modification notes now prefer repo-relative paths when rollout evidence includes absolute paths, and they also recognize both diff-style
apply_patchtext and managed*** Update File:/*** Add File:patch syntax - generic latest requests such as bare
Continue/Run checks/Check it againor vague proxy prompts likeCan you look into it?no longer overwrite a persisted goal or synthesize a fakeincompleteNextitem when the rollout has no explicit next-step evidence; concrete question-style requests still count as meaningful goals/continuation targets
extractorMode=codex is now the preferred continuity path, but it is still treated as a companion integration rather than a blind source of truth.
Current implementation rules:
- the prompt keeps the existing schema-first structure and now adds short evidence buckets for:
- recent successful commands
- recent failed commands
- detected file writes
- candidate explicit next steps
- candidate explicit untried ideas
- reviewer warning hints now also cover more than package-manager drift: canonical-store posture, retrieval flow, and retrieval route order are treated as reviewer-visible conflict signals, while reference pointers and required services stay additive reviewer context instead of being forced into false conflicts
- Codex output must still pass local structural validation after the CLI writes JSON
- if the model output is malformed, missing required layers, or returns an evidence-empty summary while the rollout clearly contains command / file / next-step evidence, the system falls back to the heuristic summarizer
cam session saveand wrapper auto-save still prefer the latest primary project rollout and skip forked/subagent reviewer rollouts by default; explicitcam session save --rollout <path>still lets a reviewer target a specific file on purposecam session refreshuses a different provenance selector:- explicit
--rollout <path>always wins, including subagent rollouts - otherwise it checks, in order, a scope-matching pending continuity recovery marker, a scope-matching latest continuity audit entry, and then the latest primary project rollout
- scope matching is exact:
bothonly matchesboth - if a higher-priority matching marker or audit entry exists but its rollout file cannot be read, refresh fails instead of silently falling through to a lower-priority source
- explicit
- refresh provenance is about regenerating the currently active continuity from a trusted source, not about generally “grabbing the latest session”
This keeps Codex-backed continuity as the primary quality path while preserving a deterministic local fallback for degraded sessions or brittle model output.
The current implementation now exposes a minimal dream sidecar seam:
cam dream buildcam dream inspect
This sidecar is intentionally:
- additive
- JSON-only
- auditable
- fail-closed
- non-canonical
It can summarize continuity into a sidecar snapshot, surface query-time relevant durable refs, and stage pending promotion candidates, but it does not directly rewrite MEMORY.md, topic files, or the continuity Markdown files.
The reviewer-facing expansion around this seam is now split into three additive surfaces:
resumeContextfromcam session status --json/cam session load --jsonquerySurfacingfromcam recall search --json- dream-sidecar review lanes such as
cam dream candidates/cam dream review/cam dream adopt/cam dream promote-prep/cam dream promote/cam dream apply-prep
These surfaces are intentionally reviewer aids first. Subagent candidates start blocked and must be explicitly adopted before they enter the primary review lane. Durable-memory dream promote still requires explicit review and then flows through the existing reviewer/audit write path before canonical durable memory changes. Instruction-like promote, promote-prep, and apply-prep all remain proposal-only: they can stage or describe a proposed instruction update, emit a proposal artifact, and prepare manual-apply hints, but they never directly mutate instruction files. After a proposal-only promote, the candidate moves into a manual-apply-pending reviewer state instead of pretending it is still a plain approved candidate.
Read-only continuity / retrieval surfaces also stay fail-closed:
- wrapper startup may rebuild the latest primary dream snapshot when
dreamSidecarAutoBuild=true cam session status/load,cam memory,cam dream inspect,cam recall, and retrieval MCP stay read-only and only surface diagnostics when sidecars or team indexes are missing/stale
Even when users prefer project-folder-local files, git worktrees do not provide a single shared filesystem path for all worktrees.
That means:
- project-folder-local storage is best for worktree-local continuity
- companion storage is still needed for cross-worktree shared continuity
This is why the implementation keeps both layers instead of trying to make one path do both jobs.
Session continuity is available by command immediately:
cam session status
cam session save
cam session refresh
cam session load
cam session clear
cam session openCommand contract:
cam session savekeeps merge semantics and remains the same path used by wrapper auto-savecam session refreshignores existing continuity during generation and replaces the selected scope from a fresh base statecam session refreshdoes not callclearbefore writing; replace means direct overwrite of the target state, not delete-then-save
cam session load now renders:
- shared project continuity
- project-local continuity
- the effective merged resume brief
- the latest continuity generation path and fallback status
- the latest continuity confidence and reviewer warnings when present
- the latest rollout path
- a small latest-generation drill-down for evidence counts and written continuity paths
- a compact prior-generation audit preview sourced from the continuity audit log that excludes the latest entry, coalesces consecutive repeats, and does not attempt to replay full prior history
cam session status now renders the latest generation path, the latest rollout path, the audit-log location, the same latest-generation drill-down, and the same compact prior-generation audit preview without printing the full shared/local continuity bodies.
cam session status --json and cam session load --json now also expose additive resumeContext, which includes the current goal, next steps, discovered instruction files, suggestedDurableRefs, and read-only suggestedTeamEntries. Those refs are resume hints only; they do not auto-promote sidecar candidates into durable memory.
cam session refresh renders a compact reviewer surface only:
- it does not print the full continuity body
--jsonkeeps the existing save payload shape and addsaction,writeMode, androlloutSelection- default
scope=bothreplaces both layers together; single-layer scopes only replace the targeted layer - in
sessionContinuityLocalPathStyle="claude"mode, replace rewrites the current active local file and does not delete historical.tmpfiles
Automatic injection and automatic saving are disabled by default.
This keeps the main auto memory contract stable and prevents temporary state from silently entering every session unless the user explicitly opts in.
When wrapper auto-load is enabled, the public startup-layering order is kept explicit and stable:
- continuity
- instruction files
- dream refs
- top durable refs
- team/shared refs
Continuity generation now keeps a separate reviewer-oriented audit log:
~/.codex-auto-memory/projects/<project-id>/audit/session-continuity-log.jsonl
Each save, refresh, or wrapper auto-save records:
- whether the preferred path was
codexorheuristic - which path actually produced the saved continuity
- why Codex fell back when it did
- a compact
confidencelevel plus reviewer warnings for conflict/noise cases - evidence counts for commands, file writes, next steps, and untried items
- the rollout path and written continuity files
trigger:manual-save,manual-refresh, orwrapper-auto-savewriteMode:mergeorreplace
This information is intentionally not written into the continuity Markdown files themselves.
Reason:
- the continuity files should stay compact and human-editable
- reviewer/debug data belongs in an audit surface, not in the working-state note itself
- the latest audit entry now remains exposed explicitly as
latestContinuityAuditEntrythroughcam session save --json,cam session refresh --json,cam session load --json, andcam session status --json - the compatibility summary field
latestContinuityDiagnosticsstill exposes the latest path/fallback view for existing consumers - those same diagnostics now also expose
confidenceand reviewer warnings so consumers can distinguish explicit evidence from conservative fallback or noisy/contradictory rollouts - the same commands now also expose raw recent audit entries so reviewers can verify a short audit window without opening the JSONL directly
- the default
load/statustext surfaces now show the latest rollout, the latest evidence counts and written paths, plus a compact prior audit preview without becoming a dedicated history browser - compact prior audit preview grouping now includes normalized
triggerandwriteMode, so a save and a refresh from the same rollout are still shown as distinct reviewer events
Recovery marker rules stay narrow:
- a continuity recovery record is still written only when audit append fails
- a successful refresh clears only a logically matching marker
- unrelated markers stay visible
- recovery metadata may include
triggerandwriteModefor explanation, but identity matching still uses the existing logical provenance fields rather than those display-oriented fields
When sessionContinuityAutoLoad is enabled, the wrapper injects a separate bounded block:
# Session Continuity
This block:
- is distinct from durable auto memory
- has its own line budget
- is framed as temporary working state
- should be verified against the current codebase and user request
The compiled startup reviewer surface now also exposes explicit additive metadata:
sourceFiles: only the source continuity files that actually rendered into the bounded startup blockcandidateSourceFiles: all candidate continuity files that were considered before the line budget was appliedsectionsRendered: whether each startup section (sources,goal,confirmedWorking,triedAndFailed,notYetTried,incompleteNext,filesDecisionsEnvironment) actually renderedomissions/omissionCounts: reviewer-visible budget trimming for source provenance and sectionscontinuitySectionKinds/continuitySourceKinds: compact structural summaries for what kinds of startup continuity were presentcontinuityProvenanceKind: currentlytemporary-continuitycontinuityMode: currentlystartupfutureCompactionSeam: a structured placeholder that marks where future compact/session-summary rebuilds should re-enter the startup contract
This keeps temporary continuity startup payloads reviewer-auditable in the same spirit as durable startup memory, while still keeping cam session separate from durable memory retrieval.
Controls the local-path layout for project-local continuity files.
"codex"(default): stores state at.codex-auto-memory/sessions/active.md— a single fixed file inside the project root. Simple and deterministic."claude": stores state at.claude/sessions/<date>-<short-id>-session.tmp— a legacy tmp-style layout. Reading picks the most recently modified file; writing creates a new file with today's date.
Switch to "claude" only if you need interoperability with another tmp-style session layout in the same project directory.
Session continuity settings are treated as local behavior:
- allowed from managed config
- allowed from user config
- allowed from local config
- ignored from shared project config
This prevents a tracked repository config from forcing another user's local continuity behavior or file layout.
The primary target is Codex.
Current Codex reality:
- rollout JSONL is available
- wrapper injection is available
- official public Codex docs clearly cover
AGENTS.mdlayering, project-level.codex/config.tomloverrides, and multi-agent workflows; local runtime observations additionally show handoff-oriented transcript context improvements - local
cam doctor --jsonon 2026-03-17 still reportsmemoriesandcodex_hooksasunder developmentand disabled, so native memory remains outside the current trusted path
Therefore the current implementation is:
- companion-first
- Codex-first in path defaults and command surface
- alternate path-style and workflow adapters remain available when needed
- wrapper-first in day-to-day operation, while future hook / skill / MCP-aware paths remain required to preserve the same continuity contract
External community patterns are useful reference material, but they do not override the Codex-first design rule.
This design was informed by official Codex docs and local runtime surface checks:
- Codex CLI overview: https://developers.openai.com/codex/cli
- Codex feature maturity: https://developers.openai.com/codex/feature-maturity
- Codex config basics: https://developers.openai.com/codex/config-basic
- Codex config reference: https://developers.openai.com/codex/config-reference
- current local
memories/codex_hooksreadiness fromcam doctor
These sources justify the current implementation choice:
- Codex-first path defaults
- wrapper-based startup injection
- optional automation rather than assuming stable native hooks
- future integration surfaces should consume continuity as auditable working state, not collapse it into opaque host-native session state
- the continuity startup contract should stay explicit about rendered provenance, section trimming, and rebuild boundaries instead of hiding them inside implementation details
The most useful ideas borrowed from community practice are:
- separating temporary session files from long-lived learned knowledge
- treating
PreCompact,SessionStart, and end-of-session hooks as distinct lifecycle moments - preserving a concise resume-oriented file instead of replaying whole transcripts
Important differences from this project:
codex-auto-memorydoes not adopt~/.claude/sessions/as its primary canonical storecodex-auto-memorykeeps shared project continuity in the companion root so worktrees can share it safely- legacy tmp-style session file paths are supported only as an adapter path style, not as the main product model
- learned skills or hook-driven recall paths may eventually consume continuity outputs, but they are still downstream integration surfaces rather than part of the continuity body itself