Import Old Claude Code and Codex Sessions Into Memory
Somewhere in the last two months of agent sessions is a decision you need today. You remember settling it: Juniper writes through a queue because the upstream service has a burst cap. You remember the afternoon it clicked. What you do not have is the session, because that conversation rolled out of context weeks ago and the connector you installed yesterday has never seen it.
Configuring memory does not backfill memory. A connector captures from the moment it goes live, and everything before that stays in local history files, beyond the reach of any current session. Pasting raw transcripts back into a chat is the obvious answer, right up until tool chatter and stale thinking blocks bury the one paragraph you actually wanted.
The agent extracts, the connector transports
Agent history import splits the job where judgment stops being reliable. Your agent reads the local history you authorize and writes a message-only JSONL extract. The connector CLI handles the deterministic half: it validates the file, previews message counts and date coverage, quotes the price for the destination, asks for approval, and uploads resumable batches under a receipt.
That split matters. A model can find the threads that matter, but a model should not decide what gets billed, or what happens when an upload drops halfway, or whether a retry creates a second copy of everything. Stable record identity and an approval gate keep the transport half boring, so nothing moves until you have seen what will upload and what it costs.
Claude Code, Codex, and OpenClaw are the supported sources, each with its own connector setup. Fetch the extraction instructions on the machine that holds the history:
npx -y memoryrouter-claude import --instructions
npx -y memoryrouter-codex import --instructions
openclaw mr import --instructions
Hand the prompt to the agent in a local session and tell it which date ranges or threads are off limits. The prompt keeps visible user and final assistant text, preserves original message IDs and timestamps, and omits tool chatter, thinking, injected memory, credentials, and duplicate records. Claude Code and Codex can run the extraction headless with --run, which launches the host CLI and can consume its inference allowance, so read the instructions and scope the local reads before you authorize it.
One message per line
Every line in the extract is one message with its original identity, not a digest of your history:
{"external_id":"claude-code:demo-session:message-1:v1","content":"For the fictional Cedar launch, the review phrase is copper-orbit-482. This is test data.","timestamp":1788912000000,"role":"user"}
Four fields, no extras: a stable external_id built from the source platform's own IDs, the message text, a Unix timestamp in milliseconds, and a user or assistant role. Because identity is stable, replaying an interrupted upload commits nothing twice, and rerunning a finished file reports duplicates instead of billing them again.
When a reviewed extract is ready:
npx -y memoryrouter-claude import --file /private/path/extract.jsonl
The uploader validates the file locally, prints counts and date coverage, gets a fresh quote from the server, and waits for you. Batches hold up to 200 records, and the receipt breaks down stored, duplicate, skipped, and failed counts to reconcile at the end. One flag worth understanding before you touch it: --yes is explicit non-interactive write approval, not a dry-run switch. Never hand it an extract you have not read.
Prove the path with a synthetic line
Run the loop on fake data in a separate test vault before real project history is involved.
- Create an
extract.jsonlcontaining the single synthetic line above. - Run that host's
import --filecommand, review the one-message preview and the quote, then approve. - Open a fresh conversation connected to that vault and ask: "Use MemoryRouter to search the imported core vault. What was the review phrase for the fictional Cedar launch? Quote the matching memory."
- The phrase comes back as
copper-orbit-482. Run the same file again and watch it land as an already-stored duplicate, with no second charge.
A model guessing the phrase is not proof. Once the synthetic line passes, the same pattern scales to real ranges: extract, review, approve, verify.
What this does not do
- It does not backfill everything. Extraction quality depends on the host model, and the uploader proves what it accepted, not that your agent found every useful thread. Deleted sessions cannot be recovered.
- It does not carry tool execution logs, file trees, images, or host configuration. Messages only.
- It does not start an ongoing sync. After the import, new conversations follow the connector's normal capture rules.
- It is not local to your machine. The extract is plaintext and approved content uploads to your vault, so keep the file outside repositories and shared folders.
The agent history import documentation has the per-host commands, the full JSONL contract, and the troubleshooting table. The integrations directory shows where this workflow sits next to the connector setup for Claude Code, Codex, and OpenClaw.
The reasoning you paid for is already written down. Whether any of it moves is your call, one reviewed batch at a time. Create your MemoryRouter account, run the synthetic line through first, and the decisions worth keeping stop being stranded in old files.