Import, Resume & Mid-Conversation Vendor Switching
AI coding sessions shouldn't be trapped inside a single vendor CLI, a single terminal window, or a single subscription's rate-limit window. Kompile treats its own local transcript store (~/.kompile/conversations/) and in-session ConversationLedger as a portable recovery source of truth, letting you:
- Import existing chat history from 11 external coding CLIs and IDEs (
claude-code,codex,agy,opencode,gemini,pi,qwen,cursor,aider,cline,continue) alongside Kompile's own sessions. - Resume a session inside its original vendor CLI, inside Kompile Standard Chat, or across vendors — handing an in-flight refactor from Claude to Codex, from Codex to Antigravity (
agy), or from any subscription CLI onto OpenRouter, Fireworks, Together, GitHub Copilot, or a local model. - Change vendor mid-conversation without closing your chat, losing your session ID, or interrupting owned background processes — manually via
/auth(/provider) or/model <vendor>:<model>, or automatically via/model failoverladders. - Recover an entire workspace of terminal sessions after a reboot or crash with
kompile resume-all. - Continue durable subagents across providers or CLIs without losing their durable ID or budget ledger (
subagent_resume).
Architecture at a glance
flowchart LR
EXT["11 External CLI / IDE Stores\n(Claude, Codex, agy, OpenCode,\nCursor, Aider, Cline, Continue, ...)"] -->|conversation_import / chat-import| STORE["Kompile Transcript Store\n(~/.kompile/conversations/)"]
KCHAT["Kompile Standard Chat &\nPassthrough Sessions"] --> STORE
STORE --> COORD["NativeResumeCoordinator"]
COORD -->|"Native session healthy\n(Outcome.PRESENT)"| NATIVE["Resume Original\nNative Session"]
COORD -->|"Native session missing or\ncross-agent handoff\n(Outcome.RECREATED)"| COMPACT["CrossAgentResumeCompactor\n(Target-Model Context Sizing)"]
COMPACT --> EXPORT["Per-Vendor ConversationExporter\n(claude / codex / opencode /\nqwen / gemini / pi / kompile)"]
EXPORT --> TARGET["Target CLI or\nKompile Standard Chat"]Supported import sources (11 external adapters + Kompile)
Kompile's ChatSourceRegistry discovers and reads conversations directly from each tool's native on-disk storage — no manual copy-paste or cloud export required:
| Source ID | Tool / IDE | Default On-Disk Location | Notes / Env Overrides |
|---|---|---|---|
claude-code | Claude Code | ~/.claude/projects/<project>/*.jsonl, sessions-index.json, history.jsonl | Honors CLAUDE_CONFIG_DIR |
codex | OpenAI Codex CLI | ~/.codex/sessions/rollout-*.jsonl[.zst], ~/.codex/history.jsonl, ~/.codex/state_*.sqlite | Honors CODEX_HOME and CODEX_SQLITE_HOME |
agy | Antigravity (agy) | ~/.gemini/antigravity-cli/conversation_summaries.db + brain/<uuid>/.system_generated/logs/transcript.jsonl | Also reads legacy cache/conversation_metadata.json & last_conversations.json |
opencode | OpenCode | ~/.local/share/opencode/opencode.db (Linux), ~/Library/Application Support/opencode/opencode.db (macOS), %LOCALAPPDATA%\opencode\opencode.db (Windows), or ~/.opencode/opencode.db | Honors XDG_DATA_HOME; reads SQLite directly |
gemini | Legacy Gemini CLI | ~/.gemini/tmp/ | Read-only import for historical Gemini CLI sessions (use agy for active sessions) |
pi | Pi Coding Agent | ~/.pi/agent/sessions/--encoded-path--/<timestamp>_<uuid>.jsonl | Native JSONL session format |
qwen | Qwen Code | ~/.qwen/projects/ | Project-scoped session transcripts |
cursor | Cursor IDE | {configRoot}/Cursor/User/workspaceStorage/<hash>/state.vscdb & globalStorage/state.vscdb | Reads VS Code SQLite storage |
aider | Aider | .aider.chat.history.md | Project-local Markdown chat history |
cline | Cline (VS Code) | VS Code globalStorage/<ext>/tasks/ | Per-task conversation folders |
continue | Continue.dev | ~/.continue/sessions/<id>.json (newer) or ~/.continue/session.db (older SQLite) | Supports both JSON and legacy SQLite |
kompile | Kompile Chat | ~/.kompile/conversations/ | Kompile's own portable transcripts |
Importing conversations
You can import transcripts from the CLI, inside an interactive chat session, or programmatically via MCP.
CLI commands
# Quick session import
kompile session import --source=claude-code
kompile session import --source=codex
kompile session import --source=agy
kompile session import-all # Import from every detected source
# Full chat-import inspector & sync
kompile agent chat-import sources # Discover installed sources + counts
kompile agent chat-import list --source=codex # List sessions for a source
kompile agent chat-import show --source=codex --id=<id>
kompile agent chat-import fetch --source=codex --id=<id>
kompile agent chat-import sync --source=claude-code # Sync all new/updated sessions
kompile agent chat-import search --query="oauth" # Search across imported transcripts
kompile agent chat-import cleanup # Prune stale/orphaned import recordsTIP
kompile agent chat-import works directly against local disk by default, or against a remote Kompile server via --remote / --url https://<host> (calling /api/chat-history/cli).
MCP tool: conversation_import
Agents connected to Kompile's MCP server can discover and import external chats without leaving the session:
| Action | Arguments | What it does |
|---|---|---|
discover | (none) | Probes all 11 external adapters and reports which tools have local conversations available |
list | source (claude-code, codex, agy, opencode, …, or all), optional limit | Lists importable sessions with IDs, titles, projects, and timestamps |
import | source, conversation_id | Imports one conversation as a portable Kompile transcript under ~/.kompile/conversations/ |
import-all | source (optional; defaults to all detected sources), optional limit | Batch-imports conversations from one or all adapters |
Resuming sessions
1. Interactive multi-tab resume browser (kompile resume / /resume)
Run kompile resume from your shell — or /resume inside an active Kompile chat — to open the multi-tab session browser grouped by agent:
# Open interactive multi-tab session browser
kompile resume
# Search and filter without opening the full browser
kompile resume --list
kompile resume --search "migration" --filter-agent claude
kompile resume --filter-source codex --list
# Inspect a transcript before resuming
kompile resume --view --session-id <session-uuid>
# Resume in its original agent or hand off to a different vendor CLI
kompile resume --session-id <session-uuid> # Auto-detect original agent (-s shorthand)
kompile resume --session-id <session-uuid> --agent codex # Resume in OpenAI Codex
kompile resume --session-id <session-uuid> --agent claude # Resume in Claude Code
kompile resume --session-id <session-uuid> --agent agy # Resume in Antigravity (agy)
kompile resume --session-id <session-uuid> --agent opencode # Resume in OpenCode
kompile resume --session-id <session-uuid> --agent qwen # Resume in Qwen Code
kompile resume --session-id <session-uuid> --agent gemini # Resume in Gemini CLI
kompile resume --session-id <session-uuid> --agent pi # Resume in Pi Coding Agent
kompile resume --session-id <session-uuid> --agent kompile # Resume in Kompile Standard Chat
# Optional: force a specific target native session UUID (-t / --target-session-id)
kompile resume --session-id <session-uuid> --agent claude -t <target-uuid>
# Export / migrate a session to another format
kompile resume --session-id <session-uuid> --migrate markdown # Formats: kompile|openai|anthropic|markdown|jsonlSupported --agent targets: auto, kompile, claude, codex, qwen, opencode, gemini, pi, agy.
2. Per-vendor resume reference
Each vendor CLI stores sessions differently and expects different native resume flags. kompile resume --session-id <id> --agent <target> normalizes all of them behind one command and dispatches the vendor's exact native resume contract:
Vendor (--agent) | Native Launch Command | Native Recovery / Recreation Behavior | Key Vendor Notes |
|---|---|---|---|
Claude Code (claude) | claude --resume <id> | Resumes existing JSONL under ~/.claude/projects/<project>/ if present; otherwise reconstructs a Claude JSONL session from ~/.kompile/conversations/ | Honors CLAUDE_CONFIG_DIR; preserves working-directory project hash |
OpenAI Codex (codex) | codex resume <id> | Resumes healthy native rollout directly; on reconstruction or cross-vendor handoff, always allocates a new native session ID | New-ID invariant prevents collisions with Codex's state_*.sqlite durable thread/queue state |
Antigravity (agy) | agy --conversation <id> | Resumes native Antigravity conversation directly (and uses ACP session/resume on managed ACP routes) | Reads conversation_summaries.db and brain/<uuid>/.../transcript.jsonl |
OpenCode (opencode) | opencode --session <id> | Attaches deterministically to the SQLite session in opencode.db or reconstructs one from Kompile transcripts | Uses --session <id> rather than --resume (OpenCode's --resume opens an interactive picker) |
Qwen Code (qwen) | qwen --resume <id> | Resumes native Qwen session or reconstructs under ~/.qwen/projects/ | Supports cross-vendor handoff from any imported source |
Gemini CLI (gemini) | gemini --resume <id> | Resumes native Gemini session or reconstructs under ~/.gemini/tmp/ | Use agy for active Antigravity sessions; gemini for Gemini CLI |
Pi Coding Agent (pi) | pi --session <id> | Attaches deterministically via --session <id> under ~/.pi/agent/sessions/ | Deterministic session attach (Pi's --resume opens a picker) |
Kompile Standard Chat (kompile) | kompile chat --resume <id> --mode standard | Restores ConversationLedger directly into Kompile's own agentic loop | Works with every configured direct provider: Anthropic, OpenAI (API or ChatGPT OAuth), OpenRouter, Fireworks, Together, GitHub Copilot, Gemini, ACP, and kompile-local |
3. Fast Standard Chat resume flags
When working directly in kompile chat:
kompile chat --continue # (-c) Resume the most recent session in this project
kompile chat --resume <id> # (-r) Resume a specific session ID
kompile chat --list # (-l) List recent sessionsYou can also switch providers or models at resume time — for example, resuming a transcript originally created with Anthropic or imported from Codex directly onto OpenRouter, GitHub Copilot, Fireworks, Together, ACP, or kompile-local:
kompile chat --resume <id> --provider openrouter --model anthropic/claude-sonnet-4-5
kompile chat --resume <id> --provider github-copilot --model gpt-5.6-sol
kompile chat --resume <id> --provider openai --auth oauth --model gpt-5.6-sol4. Programmatic MCP tool: resume
Agents can inspect, migrate, or prepare resumes through the resume MCP tool (action=list|search|show|resume|migrate), keeping cross-session continuity accessible inside automated workflows.
Changing vendor mid-conversation
You do not have to exit chat, start over, or lose your transcript when you want a different vendor's model, a different account/credential, or a backup provider mid-task. Kompile supports live mid-conversation vendor switching across the terminal REPL, the Web Harness, native passthrough mode, and automatic failover ladders.
flowchart TD
TRIGGER["Mid-Conversation Change\n/auth (/provider) • /model\nWeb /model vendor:model\n/model failover ladder"] --> KIND{"Same provider\n& same route?"}
KIND -->|"Yes (e.g. Sonnet → Opus\non Claude Code or OpenCode)"| KEEP["Keep Provider Session & Process\n• Live child process & tasks survive\n• Idle model / effort / fast sync immediately"]
KIND -->|"No (different vendor, auth route,\ncredential, or base URL)"| GUARD{"Turn currently\nstreaming?"}
GUARD -->|"Yes (manual switch)"| REFUSE["Refused Mid-Turn (Safe)\nRetry after current response finishes"]
GUARD -->|"No (or replay-safe failover)"| REBUILD["Rebuild Wire History From ConversationLedger\n• Same REPL, session ID, transcript & background tasks\n• Provider-neutral canonical replay (safe across API formats)\n• Refresh context window, cost source & Judge backends"]1. Terminal Standard Chat (/auth, /provider, /model)
Inside any running kompile chat session:
/auth(alias:/provider) opens the interactive route picker in the terminal's temporary modal window and walks through vendor → authentication route (OAuth/native login vs. API key) → stored credential (or sign in / add another) → base URL (if required) → model. Nothing is committed until you pick a model; pressingEsccancels without changing the active route./modelopens directly on the model page for the current vendor (with an option to step back to the vendor page), or/model <id>switches models immediately.
What Kompile preserves when you switch mid-conversation (AgenticChatLoop.changeDirectSettings):
- Same provider & same route (for provider-owned sessions such as Claude Code or OpenCode — e.g., changing from Sonnet to Opus or adjusting
/thinking//fast): Kompile keeps the provider's live session and child process intact (keptProviderSession=true), preserves running background tasks, and syncs the updated model/effort/fast settings immediately. - Different vendor, auth method, credential, or base URL (e.g., Claude Code → OpenAI ChatGPT OAuth, Anthropic API → OpenRouter/Fireworks/Together/GitHub Copilot, or switching between two named credentials on the same vendor):
- Kompile keeps the same REPL, session ID, saved transcript,
ConversationLedger, and owned background processes (even background tasks started under Claude Code remain controllable in your process panel). - Because provider-specific tool-call wire envelopes cannot safely cross API formats,
rebuildDirectHistoryForProviderSwitch()clears the old wire envelope and replays the provider-neutral canonical transcript fromConversationLedgeronto the new vendor's API format. - Native provider compaction checkpoints are replayed only when the provider and model still match; otherwise Kompile replays the portable ledger entries cleanly.
- Session metrics, context-window display, billing attribution (
/cost), and Judge backends (route-switch) update immediately for the new vendor.
- Kompile keeps the same REPL, session ID, saved transcript,
- Mid-turn streaming safety guard: If you attempt a route switch (changing vendor, auth method, credential, or base URL) while an assistant response is actively streaming, Kompile refuses the switch cleanly (
Provider route change refused mid-turn — retry after the response finishes) so an in-flight turn's wire history is never corrupted. Same-route model, effort, and fast-mode tweaks still apply safely.
2. Web Harness (kompile chat --web) & Native Passthrough Mode
In the browser workspace and native passthrough sessions, you can switch freely between standard vendors (OpenAI, Anthropic, OpenRouter, Fireworks, Together, GitHub Copilot, kompile-local, etc.) and native passthrough frameworks (claude, codex, opencode, agy, etc.) inside the same chat:
/provider: Opens Session configuration → Chat route in the browser; choosing a new vendor, auth route, credential, and model applies to the chat's next message while retaining the session transcript./model <vendor>: Lists live models for<vendor>without changing your current route yet./model <vendor>:<model>: Switches the active chat mid-conversation onto that vendor and model — for example:
/model openrouter:anthropic/claude-sonnet-4-5
/model openai:gpt-5.6-sol
/model claude:sonnet
/model codex:gpt-5.4What happens under the hood when crossing between passthrough frameworks and standard vendors:
- Passthrough framework → Standard vendor: Kompile hands the chat's saved transcript to Kompile's own harness (
WebCommandResolver.switchToStandardVendor) and continues on the chosen vendor/model. - Standard vendor or Framework A → Framework B: Kompile calls
NativeResumeCoordinator.seed(...)to create a brand-new native session pre-seeded with the chat's transcript (compacted for the target model's context window if needed), ensuring no previously recorded native session ID from another framework is ever overwritten.
3. Automatic mid-conversation failover (/model failover)
If your active vendor or account hits a quota wall (QUOTA_EXHAUSTED) or configured rate-limit trigger mid-conversation, you can let Kompile switch vendors/accounts automatically instead of waiting hours for a reset:
/model failover # Interactive failover ladder wizard (alias: /model ladder)
/model ladder status # Inspect configured rungs, cooldowns, and active state
/subagent-config failover # Independent failover ladder for delegated subagentsHow automatic mid-conversation failover stays safe (SessionModelLadder + ModelFailoverController):
- Multi-vendor and multi-account rungs: Each rung specifies a provider, authentication route, named credential (or native login), model, and supported thinking effort — so you can fail over from Claude Account A → Claude Account B → OpenAI Codex → OpenRouter → local model in exact order.
- Layered config: Stored in
~/.kompile/model-ladder.json(global default) with per-session overrides and runtime cooldown state in~/.kompile/conversations/<id>.model-ladder.json. Credentials are stored by reference name only, never raw secrets. - Volatile by design: Automatic failover switches the live session via
updateChatConfigForFailover(...)without overwriting your saved primary provider/model — your next session (or an explicit/model//authchoice) returns to your preferred primary. - Replay-safe request boundaries only: Failover only retries when the failed request produced no partial output or provider-native tool side effects. Completed Kompile tool calls/results stay in the transcript once; model refusals never trigger failover. If every rung in the ladder is exhausted, Kompile falls back to its existing wait-for-reset watchdog (
UsageLimitAutoContinue).
See Session Model Failover Ladder for the full ladder schema and cooldown rules.
How native reconstruction & cross-agent compaction work
Two internal components make resuming reliable even when native files disappear or models have mismatched context windows.
NativeResumeCoordinator: never corrupt a healthy session
- Kompile transcripts are the recovery source of truth: every managed session and imported conversation lives in
~/.kompile/conversations/. - Healthy native sessions are never rewritten (
Outcome.PRESENT): if the target vendor CLI still has its native session intact on disk, Kompile resumes it directly without touching its files. - Missing native sessions are reconstructed (
Outcome.RECREATED): if the native session was pruned, lives on another machine, or originated in a different vendor, Kompile reconstructs a native session file via its per-vendorConversationExporter(claude,codex,qwen,opencode,gemini,pi; Antigravityagyresumes natively over ACP viasession/resume). - Codex always-new-ID invariant: When reconstructing a missing or cross-agent session for Codex, Kompile always allocates a new native session ID rather than reusing the old ID. Codex's durable thread/queue state (
state_*.sqlite) is keyed by session ID, so forcing a reconstructed rollout onto a previously registered ID can conflict with Codex's internal state.
CrossAgentResumeCompactor: target-aware context budgeting
Moving a long conversation from a 1M-token model (e.g., Gemini or Claude) onto a smaller context window — or handing off a dense multi-hour session — would normally overflow the target model's prompt limit. CrossAgentResumeCompactor prevents that automatically:
- Target-model window lookup: Computes the safe export budget from the target provider and model (
ModelContextWindows, plus liveOpenCodeModelMetadataResolvermetadata when targeting OpenCode) — reserving headroom for system instructions and model output. - Verbatim recent tail: Preserves the 2 to 8 most recent turns verbatim (capped at one-third of the export budget / 40k tokens) so exact code snippets, diffs, and current instructions stay intact.
- Staged summarization: Older history is summarized in 16k-token chunks (up to 8 compaction stages) until the reconstructed handoff fits cleanly inside the target model's context window.
Batch workspace recovery (kompile resume-all)
After a reboot, terminal crash, or IDE restart, kompile resume-all (or /resume-all inside chat) restores all recently active sessions in fresh terminal windows.
# Default: sessions active in the last 30 minutes
kompile resume-all
# Inspect before launching
kompile resume-all --list # Show exact sessions that would launch
kompile resume-all --dry-run # Print exact terminal commands without launching
# Scope by time, count, agent, or project
kompile resume-all --active-within 60 # Active in the last 60 minutes
kompile resume-all --recent 5 # 5 most recently active tracked chats
kompile resume-all --all # Every resumable tracked chat
kompile resume-all --agent claude # Only Claude sessions
kompile resume-all --project /path/to/repo # Only sessions for one project
kompile resume-all --yes # Skip interactive confirmation
# Configure terminal launcher & maintenance
kompile resume-all --status # Show session registry + detected terminal
kompile resume-all --set-terminal ghostty # Persist preferred terminal emulator
kompile resume-all --set-terminal-args "-e"
kompile resume-all --set-recent 20 # Persist default --recent count
kompile resume-all --prune 30 # Remove tracked entries older than 30 daysDead-PID detection & lock repair
- Running sessions are never duplicated:
resume-allchecks each session's recorded PID and excludes live sessions automatically. - Crashed sessions become resumable automatically: if a process died without clean shutdown, dead-PID detection marks it eligible for recovery.
- Repairing stuck locks: if a hard power loss or corrupt shutdown leaves an abandoned resume claim, clear it cleanly:
kompile resume-all --unlock <session-id> # Release one stuck session lock
kompile resume-all --unlock-all # Repair all abandoned claims + dead-PID rowsResuming durable subagents (subagent_resume)
Subagents launched with task, multi_task, or quorum_task can also be inspected and resumed by their durable session_id or saved name via the subagent_resume tool:
| Action | Key Parameters | Purpose |
|---|---|---|
list | limit (default 20) | Lists resumable durable subagents (named/opt-in native runs and completed durable MCP tasks) |
show | session_id, limit | Inspects metadata, status, and newest transcript turns |
resume | session_id, prompt, optional agent / agent_type / role / provider / model / credential / background | Continues the subagent under the same durable ID as a child of the current caller |
cancel | session_id (live run ID) | Stops an actively running subagent |
Important guarantees enforced by SubagentResumeTool:
- Cross-agent & cross-provider continuation: You do not need the original vendor session or credentials to resume a durable subagent — any configured CLI (
agent=codex|claude|opencode|gemini|qwen|pi|kompile) or nativeprovider/model/rolecan pick up where it stopped. - Cumulative budget continuity: A resumed subagent keeps its existing token spend, dollar cost, and active runtime totals. Dispatch parameters (
token_budget,cost_budget_usd,context_ceiling_tok) can only lower the harness limit, never raise or reset it. Granting a fresh budget is exclusively a user action via/subagent-config refresh <subagent-id>. - Fail-closed CLI permission ceiling: Vendor CLIs cannot enforce a restricted caller's filtered tool allowlist. If a restricted caller tries to resume through a full-access vendor CLI child, Kompile fails closed and requires resuming via a native
agent_type/roleinstead.
Related guides
- Session Management CLI Reference —
kompile session,kompile resume,kompile resume-all,kompile stats - Quickstarts by Audience — Vendor-specific import & resume steps for Codex, Claude, Antigravity (
agy), OpenCode, GitHub Copilot, OpenRouter, Fireworks, and Together - Persistent Memory — How facts, rules, and preferences persist across sessions independently of transcripts
- Subagents & Orchestration — Durable subagents, role routing, and budget caps
- Cost & Quota Estimation — Tracking spend across resumed and cross-vendor sessions