Session Migration in Practice: Rebuilding Conversation Context Across Platforms
This article explains how to migrate an AI conversation from one client or platform to another by exporting its session state, cleaning the raw export into portable plain-text context, compressing long histories by information value, and rebuilding the session with a structured first prompt. It includes a practical cleaning script, a prompt template, and a post-migration verification checklist to help you preserve reasoning progress when usage limits change.
1. The Problem: Conversations Are Locked to a Single Entry Point
Many large model services have recently adjusted limits on conversation turns and concurrency for web and app clients. From the user’s side, the effect is straightforward: a long conversation that has accumulated a large amount of background can suddenly no longer move forward. The real difficulty is not the quota itself but the lack of portability of context assets. The model does not store your project background; it is re-fed the message history on every request. Once an entry point is restricted, the hundreds of thousands of tokens invested earlier become sunk cost.
The technical topic of this article can therefore be stated in one sentence: how to export the session state bound to a specific client as platform-independent plain-text context, and rebuild it in any inference entry point that supports long context.
2. Why the Raw Export Cannot Be Reused Directly
Session exports from mainstream chat products are usually JSON files built for front-end rendering and the product’s own state restoration, not for migration. A typical structure contains a large amount of metadata that has nothing to do with inference:
{"conversation": {"id": "c-8f2a...","title": "Order System Refactor Plan","create_time": 1730000000,"model_config": { "temperature": 0.7, "top_p": 0.9 },"plugins": [{ "type": "code_interpreter", "state": "idle" }],"messages": [{"msg_id": "m-01","role": "user","content": [{ "type": "text", "text": "..." }],"feedback": null,"parent_id": null,"extra": { "attachments": [], "citations": [], "tokens": 1284 }}]}}
Handing this file to another model as-is creates three kinds of problems. First, noise fields consume the context window. Second, multimodal blocks, citation blocks, and plugin states exist as nested structures that a plain-text model cannot parse. Third, role boundaries are unclear, so the model may mistake tool output for user instructions. The first step of migration is therefore not copying but structured cleaning.
3. Preparation Before Migration
- Check where export is available. Desktop browsers usually trigger a download directly on the page. Mobile clients mostly offer only a share link, so you need to copy the link and open it in a browser to complete the download, avoiding file loss inside an in-app WebView.
- Prefer a parseable format. JSON is better than rich text, and plain text is better than screenshots. Screenshots permanently lose structural information.
- Make a full backup. Keep the original file untouched and do all cleaning on a copy, so you can roll back if something goes wrong.
- Record key parameters. Sampling settings such as temperature and maximum output length are transferable information and should be copied out separately rather than left to the new platform’s defaults.
4. Cleaning: Compressing the State File into Pure Context
The goal of cleaning is a three-part text: task definition, confirmed facts, and open questions. A script can handle this in bulk, and the logic is not complicated:
import json, reKEEP_ROLES = {"user", "assistant"}def flatten(msg):parts = []for block in msg.get("content", []):if block.get("type") == "text":parts.append(block["text"])return "\n".join(parts).strip()def clean(src, dst, max_turns=40):data = json.load(open(src, encoding="utf-8"))msgs = data["conversation"]["messages"]out = []for m in msgs:if m.get("role") not in KEEP_ROLES:continuetext = flatten(m)if not text or text.startswith("[tool_result]"):continueout.append(f"### {m['role']}\n{text}")# Keep only the most recent turns; fold earlier content into a summary placeholderif len(out) > max_turns:head, tail = out[:6], out[-max_turns:]out = head + ["### system\n[Earlier conversation folded; see summary]"] + tailopen(dst, "w", encoding="utf-8").write("\n\n".join(out))clean("raw.json", "context.md")
Four rules govern what to keep and what to drop:
- Drop state. Message IDs, parent pointers, timestamps, feedback flags, and plugin run states all go.
- Drop duplicates. Products often store both the user message and a rewritten retrieval query; keep only the semantically complete one.
- Drop stale content. Anything containing temporary links, one-time verification codes, or expired session URLs must be removed, since it is useless and a leak risk.
- Keep conclusions. Every “confirmed / rejected / selected” decision must be preserved; this is the most critical part for restoring reasoning progress.
5. Context Compression: A Second Slimming Pass for Long Conversations
If the cleaned text still exceeds the window, do not simply truncate the head. Compress in layers by information value:
- Conclusion layer: the final plan, interface contracts, and data structure definitions, kept verbatim.
- Constraint layer: performance targets, compatibility requirements, and code style conventions, rewritten as bullet items.
- Process layer: failed attempts and overturned assumptions, compressed to a one-line conclusion each.
- Noise layer: small talk, thanks, and repeated confirmations, discarded outright.
A practical approach is to let the model do recursive summarization: summarize in segments first, then summarize the set of summaries, and fix the outermost output to three sections — “fact list / open questions / next step” — so work can continue after compression.
6. Rebuilding the Session in the New Entry Point
The first prompt after migration determines recovery quality, so it is worth templating:
You are a senior backend developer. Below is a context summary from an earlier session. Continue from it and do not ask again about information already known.[Project background] ...[Confirmed decisions] 1. ... 2. ...[Key code/structure] ...[Open questions] ...[This turn's task] Give the concrete implementation steps for sharding the orders table.
Three points matter. State the role and domain explicitly so the model does not probe from scratch. Put open questions up front to steer it toward incremental output. Ask it to list assumptions when information is missing instead of coming back with questions, which reduces turn consumption.
On the integration side, beyond a platform’s built-in quota, most AI coding tools and chat clients let you fill in a custom API base URL and key, so you can connect to an inference service that is compatible with the OpenAI protocol and pick a historical model version that is still available, preserving continuity beyond the limit. When using your own key, note that the key is stored only in the local client; never write any credentials into the exported context file.
7. Post-Migration Verification Checklist
- Factual consistency: spot-check three to five confirmed decisions and see whether the new session restates them correctly.
- No duplicated work: the new session should not ask again for requirement documents already provided.
- Style continuity: output format, naming conventions, and language should stay consistent with the earlier session.
- Cost control: watch first-turn token usage; if it is abnormally high, the noise was not cleaned out properly.
8. Conclusion
The essence of session migration is turning “a chat history inside a product” into “a context asset you own.” Handle export, cleaning, compression, and rebuilding, and a change in quota policy becomes just a matter of switching entry points. It is worth fixing the cleaning script and the prompt template in a local repository to form a reusable migration pipeline, and building the habit of distilling conclusions into a document as you go, so your context no longer depends on the existence of any single platform.
