Repository navigation
feat: import Claude Code and Codex sessions - #4342
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7ef1c7b8d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Extend a rollback cutoff only over records that share a defined turn id. - Keep tool-call arguments verbatim instead of rewriting image-shaped values. - Keep media from an assistant projection that its matching response lacks. - Count unknown event and projection kinds as unrecognized source content.
🦋 Changeset detectedLatest commit: fcd4e2b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Follow the Codex /import format: each source turn becomes an ordinary user message and one assistant message, tool calls and results become tagged text notes clipped to 2,000 and 4,000 characters, and thinking, source events and injected context stay only in the full history attachment. A final user notice records the source session, included turns, attachment paths and known limitations. Prefer a user-set title over later generated ones and fall back to the first prompt line, treat agent-name rows as metadata, stop reporting missing reasoning text, return EMPTY_SOURCE_HISTORY for sources without a prompt, and explain why forked or restarted Codex sessions are rejected.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 201dae53c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Add /import-sessions and `kimi import-sessions`, which open the same page: scan recent Claude Code and Codex sessions, choose the last 15 days (the default) or 30 days, import the newest 100 with progress, and summarize what was imported and skipped. Reruns skip sessions imported before. Imported sessions are written into the workspace of their original folder with their title, last activity time, and synthesized turn records, using the migration-legacy session writer, and show a [Claude Code] or [Codex] badge in /sessions. Discovery lives in session-import and leaves out subagent, non-interactive, and prompt-less sessions. Sessions still being written are reported as in use, and fallback titles skip lines without letters or digits.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51ec78679c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
/import-sessions writes sessions straight to disk, which the running session index only noticed on its next periodic reconcile, so /sessions missed them until a restart or up to a minute later. Look each imported session up by id after the run so the index records it immediately.
Records without text of their own, such as titles, mode changes, and request dumps, were kept three times in the full history attachment: in a header list, as the step text, and again in the step's source metadata. Keep them only as the step text with the source line in the metadata, and do the same for unknown content blocks and unknown Codex response items. On local sessions the attachments shrink from 346 MB to 141 MB for 240 MB of source files.
Render the imported history as a single user message: a system note before and after it, session info, attachment locations, known limitations, and the included turns. Every tool call keeps the first 2,000 characters of its recorded input instead of three picked fields. The session list shows the last real prompt from the source.
Claude Code 2.1.300 and later write API request records into the session file. Their message copies were read as conversation records, which duplicated tool calls and results and wrote the request log into the full history attachment.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d33e913fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Size the imported message from the default model's input limit and keep it below the automatic compaction threshold, so continuing an imported session does not start with a compaction or an over-limit request. Sessions whose project folder no longer exists are left out when scanning, so they no longer take the newest-100 slots of every run.
Link a Claude Code record to its parent even when the parent was written after it, placing the parent first, instead of cutting the history there. Titles and last prompts skip IDE context ahead of the request and image reference lines. Codex tool search results and three recent Claude Code metadata records are no longer reported as unrecognized content.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7e0061cedf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Take the last record that no other record names as its parent as the end of a Claude Code conversation, so a parent written after its child at the end of the file no longer hides the final prompt. On filesystems without hard links, publish attachments with an exclusive copy instead of failing the import.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae8b011aa5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Resolve the default model through its overrides, as the engine does, before taking its input limit, so an override that lowers the context size also lowers the import budget.
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Save the source session file in the import's attachments, minus Claude Code's API request log, together with its Claude Code folder of subagent transcripts and saved tool output, so history from before compaction and abandoned branches outlive the source files. The imported message says what the full history and the copy each hold, and clipped tool notes point to the full history.
- Copy the rollouts of the subagent threads a Codex session spawned under source/subagents/. - Show what the user did during a turn (interruptions, slash commands, messages sent while the agent worked, Codex shell commands) as [user_event] notes. - Show the work recorded after a source compaction with its summary instead of dropping it. - Title Codex sessions with the thread name from Codex's state database. - Point omitted media and injected source context to the attachments that keep them.
…ts turn - Show work and commands recorded before a turn's prompt at the start of that turn, including Codex work before the first prompt, instead of dropping them without a summary. - Wait up to 3 seconds for a Codex state database lock before falling back to the first prompt as the title.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77ab5346a3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- When a turn starts, claim only the records written before it that can open a turn (user input and context), so a rollback no longer drops the previous turn's answer and tool work in sessions that mix records with and without turn ids.
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Requirement or Bug
把最近在 Claude Code 和 Codex 里的会话导入 Kimi Code,让用户接着之前的工作继续。
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
另外更新了中英文的会话指南、
kimi命令参考和斜杠命令参考,同步了工作区、lockfile、Nix 清单和项目地图。导入后的会话以一条普通、可见的用户消息开头:
转换规则
[external_agent_tool_call: 名称]加来源记录的输入前 2000 字符,结果写成[external_agent_tool_result]加前 4000 字符,来源标记出错时加: error,被截断的地方带指向完整历史的标记。所有工具同样处理,格式参照 Codex 0.163.0 的/import。SOURCE_CHANGED。## My request:之前的部分)和图片引用行,最多 120 字符。会话列表里的“最后一次提问”按同样规则取自来源。complete;partial带具体原因(预算省略、未识别内容、加密压缩等);unreliable带错误码,不写入会话。没有任何提问的会话返回EMPTY_SOURCE_HISTORY;Codex 里经过 fork 或从之前消息重新开始的会话返回UNSUPPORTED_HISTORY_BASE。导入预算:转换包默认用窗口的 80%,调用方可以传入
tokenBudget。Kimi Code 按默认模型计算:loopControl配置。导入流程
/import-sessions和kimi import-sessions打开同一个页面:默认选最近 15 天,另有最近 30 天和取消;页面显示各来源的数量,以及不计入的已导入数量和项目目录已不存在的数量。ses_<来源会话 ID>,重跑会跳过已导入的会话。Behavior Changes and Affected Users
/import-sessions(仅空闲时可用)和kimi import-sessions(需要交互终端)[imported][Claude Code]/[Codex],其他会话不变convertSession()和findSessions()tokenBudget;不调用就不读不写apps/kimi-code/src/cli只新增一个子命令,已有子命令、选项和输出格式不变;未改引擎、SDK 和会话格式测试覆盖
真实会话验证
complete,16 次partial(预算省略、Claude Code 的tool_reference块、Codex 加密压缩),2 次EMPTY_SOURCE_HISTORY,2 次 Codex fork 会话的预期拒绝。每个结果都是一条用户消息,首尾说明完整,不超预算;图片哈希与索引一致,完整历史中没有重复的工具调用,重复转换的结果一致。kimi import-sessions,写入临时主目录。导入了 12 个会话,每个都带源文件副本;再次运行时全部显示为已导入;kimi session list --all列出 12 个。临时目录已删除。已知限制
file-history)和任务工作目录里的文件。新增 changeset(
@moonshot-ai/kimi-codeminor):“Add/import-sessionsandkimi import-sessionsto import Claude Code and Codex sessions from the last 15 or 30 days. Run either one and choose a time range.”Checklist
/approve).(无关联 issue;需求见上文。)gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.