kimi-code/docs
Kai 4a24ae1238
feat: import Claude Code and Codex sessions (#4342)
* feat: add standalone session import conversion package

* fix(session-import): address rollout and image review findings

- 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.

* feat(session-import): render imported history as visible messages

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.

* feat: import Claude Code and Codex sessions

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.

* fix: list imported sessions in /sessions right away

/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.

* fix(session-import): store each source record once in the full history

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.

* feat(session-import): import the conversation as one framed user message

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.

* fix(session-import): skip the Claude Code API request log

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.

* fix: fit session imports to the model and skip missing folders up front

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.

* fix(session-import): keep late-written parents and clean up titles

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.

* fix(session-import): find the chain end and publish without hard links

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.

* fix: apply model overrides before sizing session imports

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.

* feat(session-import): keep a copy of the source session with each import

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.

* feat(session-import): keep more of the source session in imports

- 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.

* fix(session-import): show what came before a prompt at the start of its 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.

* fix(session-import): stop a Codex turn start from claiming earlier turns

- 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.
2026-10-26 13:48:16 +08:00
..
.vitepress docs(tower): add description (#4216) 2026-10-15 12:56:05 +08:00
en feat: import Claude Code and Codex sessions (#4342) 2026-10-26 13:48:16 +08:00
media docs(zh,en): restyle configuration and customization sections (#3485) 2026-09-03 16:12:29 +08:00
public Kimi For Coding 2026-05-22 15:54:50 +08:00
zh feat: import Claude Code and Codex sessions (#4342) 2026-10-26 13:48:16 +08:00
.gitignore fix: fix bundle (#956) 2026-06-22 13:59:57 +08:00
AGENTS.md docs: rename permission modes to Always Ask, Ask When Needed, and Never Ask (#3406) 2026-08-31 23:02:07 +08:00
index.md Kimi For Coding 2026-05-22 15:54:50 +08:00
package.json feat(web): add Mermaid diagram rendering and off-thread KaTeX/Mermaid workers (#1226) 2026-07-01 02:17:34 +08:00