Importing other agents' sessions
| Module | Job |
|---|---|
claude_code.py, codex.py | Find, summarise and parse each format |
model.py | Neutral shape: turns of user text and ordered reply blocks |
sanitize.py | Drop host scaffolding, remove credentials |
writer.py | Write turns as the DAG a native turn produces |
ledger.py | What was imported where |
service.py | list_candidates, plan_imports, import_transcripts |
Entry points: openprogram sessions import, /api/sessions/import, the Import settings tab. The CLI sends batches to a running Worker, else writes the store directly. Product page: Session import.
Reading the formats
| Claude Code | Codex | |
|---|---|---|
| Files | projects/<slug>/<id>.jsonl | sessions/YYYY/MM/DD/rollout-*.jsonl |
| Source id | File name; sessionId is copied into forks | session_meta.id |
| Conversation order | Chain walked back from the newest record through parentUuid / logicalParentUuid | File order; compaction and forks do not rewrite it |
| Title | custom-title, then ai-title, then summary | session_index.jsonl, latest rename |
| Model, cwd | message.model, record cwd | turn_context.model, session_meta.cwd |
| Skipped | isMeta, isSidechain, compact summaries, API error records | Sub-agent rollouts, injected context blocks, encrypted reasoning |
A line that is not a JSON object, or a record still being written, is skipped; the rest of the file still imports.
Decisions
| Choice | Why |
|---|---|
| Read the conversation the way its own agent resumes it | Claude Code's resume follows the parent chain from the newest record; Codex replays the rollout in order. The imported conversation is then the one the user last saw there, not abandoned branches. |
| Write native nodes, not an attachment | Search, export, rewind and continuing the conversation work unchanged. Tool calls whose tools do not exist here are replayed to the model as text. |
| Ids derived from agent, source id and turn index | Writing a turn twice is a no-op, so a grown source appends in place. Same principle as OpenCode's import, which keys an imported session by its original id. |
| Ledger with last fingerprint and head | Unchanged sources are skipped without a parse. A rewound source, or a session continued here, becomes a new session, so nothing already here is rewritten. |
| Recency from the last message, not file size or mtime | A running agent keeps appending bookkeeping records to a transcript whose conversation has not moved. |
| Credentials removed with the request-redaction shapes | An imported turn is replayed to whichever model continues it. The high-precision shapes from models/providers/utils/redaction.py catch keys and tokens without rewriting prose that only mentions a key or a token; export's broader rules would. A title is cleaned before it is cut to length, since a key cut short no longer matches its shape; the listing's scan cache keeps its first message and titles cleaned too. Sign-in files are never opened. |
| Placed in the folder's project | Same as opening that folder here; the original cwd stays in imported_from.cwd. |
--dry-run beside --list | --list shows every transcript and its state; --dry-run shows only what the same command would create or append to. It runs plan_imports, the same decision the import makes, so a rewound source shows as a new conversation, not an append. |
Implementation status
- Only the default homes (or
$CLAUDE_CONFIG_DIR,$CODEX_HOME) are scanned; a copied folder from another machine cannot be named on the command line. - A session imported before credentials were removed keeps what it holds until its source grows; then only the last imported turn is rewritten clean. A turn's fingerprint is taken from its text as read, so redaction never turns such a source into a duplicate session.
Last updated · 2026-11-25