Repository navigation
feat(kap-server): stream agent conversations as turns and items - #4663
Conversation
The turn machine's message accumulator now reports which content block each streamed part lands in. The block index rides on the turn machine's forwarded parts, the engine delta, and the assistant.delta and thinking.delta events, and is written on every content.part record, so streamed blocks and persisted parts share one identity. Each content.part record also carries when the block's first delta arrived and how long the block streamed (startedAt and durationMs), so a reasoning block's duration survives a reload. The loop's salvage buffer now groups parts by that block index instead of re-deriving boundaries, which leaves the accumulator as the only place that decides block boundaries. A request-level attempt retry now resets the step's stream: the turn machine signals step.stream_reset, and the loop drops its salvage buffer and publishes turn.step.stream_reset.
Replayable state keys and agent models can declare a custom onUndo; durable runtime participants could not, so an undoable participant never saw the undo-anchor user messages (they were swallowed for checkpointing) and had no way to fold the user's input. A participant may now pass onUndo: anchors reach its transition like any other message, and unpaired legacy context.undo records call onUndo instead of rolling back to a checkpoint. Participants without onUndo keep the checkpoint behaviour.
An agent's conversation is now one fold over its durable wire records,
attached to the agent's event dispatcher as an undoable participant. The
same fold serves live sessions, replay after a restart, undo (the dispatcher
replays the active branch and the feed reports removed turns), and a cold
read of the wire file for session rating.
The WebSocket subscription takes agent_ids and sends a turns frame with the
latest page, then turn.started/updated/ended, item.started/updated/ended,
item.delta, item.removed, turns.removed and notice frames. Streamed text is
held per step and block, so a running item and its persisted content share
one id. A running text or reasoning item ends as soon as the next block or
tool call of its step starts. Reasoning items carry started_at and
duration_ms from the streamed block timing; records written before block
timing fall back to the step start and the time the part was recorded. The
agent frame now carries the running turn and prompt, compaction and request
retry state.
REST serves GET /sessions/{id}/agents/{agent_id}/turns and .../plans. The
transcript package, its service, routes and WebSocket grades are removed.
code-app: 2c088fdc599a4205ad186ec74fafee1b9462d9d2
🦋 Changeset detectedLatest commit: ef90dbd 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 |
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: 9c617765a6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…on feeds User items drop bundled skill instruction blocks with the same filter the prompt list applies, so a prompt with bundled skills no longer shows the skill body as the user's text. An undo that keeps a turn but cuts items from it (a legacy steer anchor) now sends item.removed and the changed items of that turn, not only the removed turns. Search on a live session covers every agent in the session metadata and reads agents that are not loaded from their wire file, as the transcript store did through its history backfill. A conversation subscription follows its agent across eviction and resume: subscribing again, or a subagent.started event, reattaches the feed when the agent's handle changed.
code-app: c3f49a097d3b0ed28c3b951b9d837cc9a31652d2
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9678779a9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…take a caller prompt id promptWithSkills and skill activation accept an optional promptId and submit the user message under it, the same way a plain prompt does, so a client can pair its optimistic message with the echo by id. Without a promptId the loop still mints one.
…ription outcomes explicit ConversationService now creates a feed for every agent scope as the scope is created, attached before its restore, disposes it when the agent closes and drops a session's feeds when the session scope goes away. Each new feed is announced to the broadcaster, which attaches the connections subscribed to that agent and sends them a fresh turns page, so an agent restored by any path keeps streaming to its subscribers, and a subscriber that joins mid-step sees what the step has already streamed. This replaces the SubagentStarted reattachment and the per-connection feed comparison. subscribe_v2 reports the outcome: a session that cannot be opened acks with the error code (40401 also lists it in not_found) instead of a bare not_found, a main agent that fails to load fails the subscription, and an agent whose conversation cannot be loaded gets a turns.failed frame with the code and message. The turns and plans routes map the same errors. After an undo the feed resends the latest turns page instead of diffing the restored turns. User messages are projected by one function shared with the prompt list: bundled skill instructions and hook parts are dropped, retries and internal triggers other than subagent prompts show no text, and origins keep only display fields, so server paths in attachments and skill paths no longer reach clients. Interactions still pending when their turn ends, or when the agent stopped without ending it, are presented as ended. Bundled skill submissions accept prompt_id and skill activation takes prompt_id, reserved like a plain prompt. Session-scoped search goes through the index instead of reading live conversations. Rating keeps reading a closed session without loading it, and that read now rejects corrupted complete wire lines while tolerating a torn last line.
… skills in the server API
code-app: 4b94754ad85707ef4fea72bb1d941a87e5434cd8
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73cb74b20b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ol outputs The hydration check only looked for image URLs, so a tool output whose only offloaded media was video or audio reached clients as a raw blob reference. It now checks every media URL that loadParts rewrites.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca16c56ba5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
💡 Codex ReviewWhen a restored session contains a turn without AGENTS.md reference: AGENTS.md:L125-L127 For migrated or older sessions whose user message contains an AGENTS.md reference: AGENTS.md:L125-L127 When undo targets a steer inside an existing turn after one or more later LLM steps have completed, this truncates the turn's items but leaves AGENTS.md reference: AGENTS.md:L125-L127 ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…items Undoing a steer that sits inside a turn cut the turn's items after the steer but kept the steps that produced them, so the replacement page still carried their ids, finish reasons, usage and timing. The undo anchor now records the step count next to the item count and both are truncated together.
…ooks Durable runtime participants had no explicit signal for when the dispatcher replays them. A participant can now implement onWillReplay, called right before a rerun restore resets its state, and onDidReplay, called once at the end of every replay pass: the first restore, every rerun restore and the catch-up of a late attach (for the late participant only). onDidReplay also runs when the pass fails, with ok: false, so a participant never stays in a replaying state; the state it returns is committed when it differs. Hook errors are reported and do not change the outcome of the restore.
…on feeds A feed inferred a replay from receiving its initial state object and its end from the context.undone event that the undo service dispatches last. When anything failed between the restore and that event, the feed stayed in its restoring state and silently stopped emitting turn and item events for the agent. The feed now enters restoring in onWillReplay and leaves it in onDidReplay, which also resolves or rejects the first restore, so a failed first replay rejects ready. Turns that are still running when a replay ends are settled in the fold as interrupted, together with their running items and pending interactions, unless the loop or a compaction is actually running them; the cold read used by session rating settles them the same way. A page therefore no longer rewrites turns from runtime state at read time, and the next prompt can no longer end such a turn as completed. The feed serves one page(before, limit) for REST and WebSocket. A blob that fails to load keeps its stored reference and is logged instead of failing the page. Pending persistent diffs are flushed before any live item event or notice, so a client never sees an item of a turn it has not been told about.
Any user message that was not a steer opened a running turn and implicitly ended the open one. Openers without an owner never receive a turn.ended record: CLI shell commands append their input and output as user messages, and a prompt that a UserPromptSubmit hook blocks appends the hook result and the blocked message without a turn.prompt. The last such turn stayed running forever and hid the real outcome of the turn it had ended. A running turn is now opened only by a user message that consumes the matching turn.prompt, by loop events of a numbered turn, by a legacy assistant message that follows a turn.prompt (imported sessions), or by full_compaction.begin. Every other opener gets a turn that ends at once as completed and leaves the open turn alone. A blocked prompt turns its already ended turn into blocked. Implicit closes still default to completed for sessions written before turn.ended existed. Tests that appended a turn's messages without a turn.prompt now record one first, as live and migrated sessions do.
Subscription membership lived in three places: the connection's subscriptions set, the broadcaster's targets and the agents whose lists it had sent, kept in step by isSubscribed. The connection recorded a session only after the subscribe resolved, so a socket that closed while the session was opening left its target registered for good. The ack waited until every agent's page was loaded and sent while control frames ran one at a time, so one slow session held back later subscribes and the pages reached the client before the ack. When a recreated agent's feed failed to restore, nothing was sent and the old attachment stayed on a disposed feed. The broadcaster now owns membership: sessionsOf(target) serves the connections listing and removeTarget(target) runs on close, and a connection that closed while a subscribe was opening the session removes its target once the subscribe returns. A subscribe opens the session, registers the target and calls back so the connection acks at once, then sends agent lists and attaches conversations without waiting for pages. One sync(state, target, agentId) serves subscribe, feed creation and session reattach: it resolves the agent's current feed, attaches it unless it is already attached and sends its page, or detaches and sends turns.failed when the feed cannot load; an unsubscribe or a newer sync wins over one still loading. The conversation service is now required, and the broadcaster tests drive it through a fake whose loads and pages they control.
A prompt whose submission gate fails, for example because a prompt hook throws or an attachment cannot be materialized, ends without starting a turn, yet its status was projected as queued. The submit route already waits for idle sessions until the prompt launches or completes, so it now reports such a prompt as failed; the prompt status enum gains failed. Every other state keeps its status.
…bscribe ack in the server API
A turn.prompt waits in the fold until a matching user message or the turn's loop events open its turn. A turn whose opener the fold skips, such as an injection, can end before any loop event, leaving its prompt pending; the next opener that consumes a pending prompt, for example the hook result of a blocked prompt, then opened a running turn that nothing would end. A turn.ended record now also drops the pending prompt of the same turn.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec4e79795c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…er undo inside a turn With KIMI_CODE_DEBUG=1 the last item of each ended step carries the finish reason, usage and timing of its model request. An undo that cuts the items after a steer now resets subscribers, and undone turns drop their tool and interaction bookkeeping so a reused call id starts clean.
|
@codex review Please review only what is not settled below. These points were decided by the maintainer and answered in resolved threads; do not raise them again:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 375f0c3643
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ns page A replay or a context clear is now diffed against what subscribers already have, and turns that left the conversation go out as a turns.removed frame. The turns page is sent only when a connection starts receiving an agent, so the internal reset event, the resend path and its notice buffering race are gone. The in-turn truncation branch is dropped: live undo removes whole turns through a replay.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cddcf11a36
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
POST /sessions/{id}:undo takes the turn_id and optional agent_id of the
turn to undo and answers with removed_turn_ids, matching the turns.removed
frame. The feed checks that the turn exists (40421) and opens with user
input (40911), then undoes the anchors from that turn on. Action bodies
that fail validation now answer 40001 instead of an internal error.
|
@codex review Please review only what is not settled below. These points were decided by the maintainer and answered in resolved threads; do not raise them again:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c9a2330ec
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A session's attempt map is removed once its last attempt fails before enqueueing, and the whole map goes when the session is deleted, so stored responses no longer outlive their session.
|
@codex review Please review only what is not settled below. These points were decided by the maintainer and answered in resolved threads; do not raise them again:
|
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…obes B1, B7, B9, B10 and B12 have no open rows; their executable probes pass (B9/B10 carry manual probes only, so verify reports no executable probe), and each batch is marked done. B3 stays open: its MoonshotAI#4427 probe targets test/features/tower/store.test.ts, which bunfig excludes from the default suite, so the probe cannot run without the heavy path override. The MoonshotAI#4663 probe followed applyConversationRecord, which the live feed redesign removed and this branch now deletes; it points at the feed's applyMessage fold instead. The MoonshotAI#4514 probe was malformed (absent: needs <pattern>@<path>) and now checks that package.json no longer lists the removed app.
Note the rating/undo/prompt-id commits under MoonshotAI#4663 and narrow its remaining items to the /ops and transcript decisions plus the conversation test rewrite and e2e re-point.
MoonshotAI#4663 and MoonshotAI#4789 now describe the recorded-event fold that serves the pinned bundle: task links come from persisted TaskStarted records, and the feed no longer rebuilds from the model-context view. MoonshotAI#4730 moves from partial to ported (record-driven items seal once, with the recorded reasoning duration), and MoonshotAI#4772's probe follows the feed suite it now lives in. MoonshotAI#4893 is unblocked: `kap.conversation` stages its replay, publishes once after rehydration, and gates live dispatch only while a mutable participant restores. The PLAYBOOK note on the release-branch commits carries the correction for MoonshotAI#4888 for the same reason.
Requirement or Bug
desktop / web 的对话视图以前建立在 transcript 层上:服务端用两套投影生成转录(live 吃总线事件,冷读吃 wire 记录),再靠回填、overlay、轮结束后 heal、撤销后 reset 把两边对齐,经
transcript.ops增量推给客户端;客户端为此维护 seq、缺口检测、空 reset 重试,以及按文本和时间配对本地气泡。本 PR 按 KAP 草案把 agent 的对话改成"轮 / 条目":服务端对 agent 的持久化记录只做一次折叠,实时、重启后恢复、撤销、冷读共用这一个函数,页和事件都经同一个投影输出草案里的形态;WebSocket 按 agent 推送turns页和turn.*/item.*事件;整个 transcript 包删除。客户端配套:MoonshotAI/kimi-code-app#1130。连接层的信封改名(
subscribe/request_id/response)和 prompt 提交接口不在本 PR,留给下一组。Bug Reproduction Steps
N/A(协议替换)。
Root Cause
N/A
Code Changes
核心思路
applyConversationRecord(state, record)输入 agent 的 durable wire 记录,直接产出协议形态的轮和条目(ConversationTurn/ConversationItem),作为可撤销 participant 挂在 agent 的 event dispatcher 上;会话评分也经同一个回放读取。每个协议字段在决定它的记录到达时算好,conversationItems.ts只放这些字段的构造函数;状态里除了轮,只有安排后续记录用的簿记:未结束的步骤、工具与交互的关联、撤销锚点。页直接从轮里切,事件直接比较协议对象,只在分页时把blobref:媒体换成加载后的地址。onWillReplay(),每次回放(首次恢复、撤销、重跑)结束后调onDidReplay(state, { ok })。feed 据此在重跑期间暂停出页,GET .../turns和订阅页都等回放结束再返回;回放结束时把 agent 已经不在运行的轮收尾为interrupted/aborted,再拿结果和已推送的状态做差分:消失的轮用turns.removed推送,保留下来的轮只推有变化的部分;首次回放失败时 feed 的ready失败,订阅方收到turns.failed;重跑回放失败时保留回放前的历史。之前靠 restoring 标记、ContextUndone事件和isActive判断拼出来的恢复流程全部删除。ConversationService管:每个 agent scope 一创建(restore 之前)就挂上 feed,agent 关闭时销毁,会话 scope 销毁时整体清掉;新 feed 会通知 broadcaster,由它给订阅了这个 agent 的连接重新挂接并下发一页turns。所以 agent 不论经哪条路径被恢复(Agent 工具、直接 prompt、任务请求、调试接口),订阅都不会失效。subscribe_v2是追加:新加入的 agent 先收到一页turns(或turns.failed),之后是turn.*/item.*/notice。会话被接受时立即回 ack,页随后到达;会话打不开时 ack 带真实错误码(40401同时列进not_found,40930、40931等说明原因),什么都不订阅。turns.removed { turn_ids }推送被删的轮(按 ordinal 升序),客户端按 id 删除;turns页只在开始订阅(包括重连、agent 重新加载)时发送。撤销按整轮进行:POST :undo { turn_id, agent_id? }删除这一轮及之后的轮,响应{ removed_turn_ids }与推送的帧一致。turn.prompt的用户消息、带轮号的 loop 事件、紧跟turn.prompt的老格式 assistant 消息(导入的会话)和full_compaction.begin会开出运行中的轮。其他开场(例如 CLI 的!命令和输出、hook 的结果、被 UserPromptSubmit hook 拦下的输入)收不到turn.ended,现在生成一个立即以 completed 结束的轮,不再隐式结束正在进行的轮;被拦下的输入随后改为failed/blocked。!命令在草案的 shell 轮上线前按原始文本显示,origin 为system。轮结束时一并丢掉同一轮还挂着的turn.prompt。提交后没能开始轮的 prompt,状态报failed,之前显示成queued。user_message:prompt_ids只给客户端提交的来源(用户输入、技能激活、插件命令),系统触发为空数组。text、attachments、skills、origin在折叠时生成:和 prompt 列表一样用引擎的stripBundledSkillBlocks、isUserPromptSubmitHookPart去掉打包技能的说明块和 hook 块,origin 按 kind 白名单只保留展示字段,服务端路径不下发。tool_call:运行中带stage(input/awaiting_approval/executing),等待审批时带interaction_id;审批和提问的卡片只来自 interaction 帧,条目里不再嵌交互对象。ExitPlanMode 的display是折叠根据交互请求和回应算出的plan_review,所以本 PR 早先加的/plans路由删除了。notification:服务端把引擎的任务通知解析成结构化字段(标题、正文、级别、类型、来源、任务、agent、输出预览;提问任务的内联回答也算输出),客户端不再解析通知文本。system:完成的压缩是compaction条目,轮中压缩放在本轮,空闲压缩单独成system轮;被取消或失败的压缩不留条目,改发一条notice。分叉出来的 agent(侧边对话、fork)以一个带fork_boundary的system轮开头,继承来的记录不显示。outcome之外用end_reason说明结束原因(用户停止为user_cancelled,回放结束时收尾的为aborted,此外还有max_steps、error、filtered、blocked);请求重试的状态挂在运行中的轮上(turn.updated { retry });压缩期间agent帧的status是compacting。content.part一致,所以运行中条目和最终条目是同一个 id。文本增量经item.delta { field }推送,工具的阶段、进度等变化经item.updated { set }只推改动的字段。同一步里下一段内容开始时,前面运行中的文本 / 思考条目立即结束;请求重试重置这一步时,运行中的条目用item.removed移除。content.part上记下这一块第一个增量的时间和流式时长,reasoning条目据此给出started_at/duration_ms;没有这两个字段的老记录用"步骤开始 → 记录写入"兜底,content.part写在工具执行之前,所以兜底值也不含审批等待和工具耗时。prompt_id,/skills/{name}:activate新增prompt_id,和普通提交一样预留防重;客户端因此对所有气泡都按prompt_ids配对。source。协议
turn_id形如t_加 12 位十六进制,由 agent、ordinal 和开始时间算出:在会话内唯一,重新回放后不变,不复用。ordinal是轮在当前历史里的位置,撤销后可能复用;turn_number是引擎轮号,文件变更、分叉、评分继续用它。条目没有index,按追加顺序排列。failed(带error,不带output),没拿到结果就随轮结束的为interrupted。notice来自总线上的 warning / error 事件,只实时推送,不进轮。turns页里已有的内容,客户端按替换处理即可。结构
旧路径的功能清单与新位置
coreEventMap把总线事件映射成转录 opgroupTurns+foldFacts+readColdSnapshot+wireCacheresetopturns.removed推送GET /transcript?beforeGET .../agents/{agent_id}/turns?before_ordinal&page_sizeGET /transcript/plandisplay(plan_review),由折叠根据交互请求和回应算出GET /transcript/ops、GET /transcript/user-messagessubscribe_v2的 per-agent grade:决定一个连接收哪些 agent 的转录和 task / agent / usage / goal / todo 帧agent_ids:同一份"连接收哪些 agent"的记录,只存在 broadcaster 里user_message.origin/skills从记录里读出;排队的 prompt 不进对话(main 上由客户端本地管理队列)user_message.prompt_ids;打包技能与/skill激活现在也带客户端 prompt idstage: awaiting_approval+interaction_id;待处理交互照常在订阅确认后补发interrupted/aborted,运行中的工具条目随之结束notification条目;老会话里解析不出通知块的纯文本保留为通知正文notice事件compaction条目;压缩期间agent帧为compacting;没完成的压缩发noticeturn.error和end_reason,取自turn.ended记录fork_boundary轮开头,继承的记录不显示allocateExportTurn另分配)turn_id、表示位置的ordinal与引擎的turn_number分开onDidCreate)订阅它,子 agent 被淘汰后再恢复,已有订阅照常收到ConversationService在每个 agent scope 创建时挂 feed 并通知 broadcaster/turns和评分返回 40930,订阅的 ack 同样带 40930/agents/{agent_id}/turns验证同一场景ordinal按顺序分配、不随引擎轮号改写,继承的记录不显示;补了轮次唯一且有序的测试提交
按主题分组(共 55 个,另有两次合并 main):
942c1c27f流式内容块编号并记录时长;9d3628331可撤销 participant 自己处理撤销;649c08b9b打包技能提交和技能激活接受调用方的 prompt id;bca13fdf6durable participant 的回放钩子。95d616866主体(删除 transcript 包、服务、路由和 WebSocket grade,feat(agent-core-v2): enforce minimum wire reader version #4638 的版本检查移到新读取路径,更新apiSurface快照、flake.nix、AGENTS.md)。37530d44c、2eefaa6eb(feed 生命周期归ConversationService,订阅的明确结局与turns.failed,共享的用户消息投影),ca16c56ba、924dc959f。cefe84704feed 跟着回放走;455620112只有拿到turn.prompt的开场才开运行中的轮;cb2d96276订阅只记在 broadcaster;01706ede2、17567441bprompt 的failed状态与挂起 prompt 的清理;e9dca2709首次回放失败的测试;0f489c94e、03a715a21清空上下文和部分裁剪的撤销都重发整页;9b83fc28f重跑期间不出页;665058007提问任务的内联回答;242855ec9老会话里纯文本的任务消息保留为通知正文;8f5ea06ac重跑回放失败时保留原有历史;ad5c8bf73缺字段的老格式 cron 来源给出默认值;0ec35d7dc分页只为留在页里的轮加载媒体;3dea426771.4 版记录顺序的压缩摘要合并进已完成的压缩;36fc42bffCLI 的!命令重新按原始文本显示。833ebd252轮和条目;8b62d2d6a分页参数与 1 MiB 上限;b3502bee8压缩状态与agent帧;0b439d8eb搜索去掉source。83358028d合并了 fix(tui): keep wrapped Grep and Glob glance lines indented #4617、docs(changelog): sync 2.5.0 from apps/kimi-code/CHANGELOG.md #4673、chore: sync release/2026-11-04 back to main #4674。main 在已删除的 transcript 包里有两处修复,在新路径里的对应位置见下方旧路径清单的最后两行;8f088acd2去掉 prompt 路由里对 transcript 服务的调用并移植它的测试,3c19c91fa补上分叉轮次唯一且有序的测试。247df07a4合并了 feat(tui): fold tool calls and thinking into transcript groups in fullscreen #4618、perf(tui): reuse unchanged tool output lines across renders #4665、docs: rewrite remote environment guide for users #4693、chore: sync web dist from code-app #4685,冲突只在dist-web,保留本分支的产物。6eb08f029折叠直接产出协议形态,去掉投影层;用本机约 3,600 份 agent 对话记录对比新旧实现,结果一致,只有一份旧引擎在同一步号上跑了两步的记录取舍不同(现在保留后结束的那一步)。fc6e1a282工具调用 id 跨轮复用时把审批挂到新调用上,是对比时发现的旧问题。b188f087c文档写明 CLI shell 命令的轮。770751154删掉本 PR 新增测试中的大部分,只保留核心用例和从 main 改写过来的场景;e64fe5df1补回上一步误删的 S3(审批)场景;f2ee649e9保留分叉轮次唯一且有序(对应 main 的修复)和思考时长(对应下表的行为变化)两个用例。3b6ea1df9、8aa4c9a3a、d86b7d1c7、156419f54(docs/en|zh/reference/server-api.md)。9c617765a、1a2417190、967a7474a、8562f9c14。d354d9039边界情况对齐文档;cb20c878d、685e2e5ac附件文件结构化为file附件、不含服务端路径;ec4e79795步骤不再带计时;375f0c364条目的请求调试信息(仅KIMI_CODE_DEBUG=1)与撤销后清理工具记录;cddcf11a3用turns.removed取代整页重发,去掉内部reset;9c9a2330e撤销按turn_id对齐草案。edf3ab717还原成 main 上的产物,本 PR 不再改apps/kimi-code/dist-web。Behavior Changes and Affected Users
subscribe_v2的 payloadtranscript(per-agent grade)、transcript_sinceagent_ids(追加,默认主 agent)code 0,会话打不开一律not_found;主 agent 加载失败只记日志40401列进not_found;主 agent 加载失败也让订阅失败not_found判断的外部脚本turns帧为准turns.failed { code, msg }transcript.*快照与 opturns、turns.failed、turn.*、item.*、notice,形态见上resetopturns.removed { turn_ids },客户端按 id 删除;重连后重新订阅收到最新一页turnsPOST /sessions/{id}:undo{ count, page_size? }→{ messages }{ turn_id, agent_id? }→{ removed_turn_ids };未知轮40421,开场不是用户输入或跨过压缩40911GET /sessions/{id}/transcript、/transcript/ops、/transcript/plan、/transcript/user-messagesGET .../agents/{agent_id}/turns;计划从 ExitPlanMode 工具条目的display读off的连接agent_ids里的 agentagent帧的statusidle/runningcompactingrunning判断忙碌的外部脚本:压缩期间不再是runningqueuedfailedprompt_id/skills/{name}:activateprompt_idprompt_id,重复时 40927sourcelive/indexsource的外部脚本;开启了全局搜索(默认关闭)的用户在流式中的文字落盘前搜不到origintext为空,origin 标明来源!命令<bash-input>/<bash-stdout>原始标签的用户消息system,客户端不提供撤销(引擎本来就不把它们算作撤销锚点)turn.ended的轮不收尾,只有未结束的审批 / 提问冷读时标为取消interrupted/aborted,运行中的工具条目随之结束(只在投影里,不写回 wire)fork_boundary轮开头,继承的记录不显示notice { code: "compaction.cancelled" }content.partwire 记录block、startedAt、durationMsreasoning.started_at/duration_ms;老记录用"步骤开始 → 记录写入"兜底GET /transcript冷读,不恢复会话GET .../agents/{agent_id}/turns恢复会话后再读,与/messages相同;desktop / web 读历史时本来就已订阅(订阅会恢复会话),不受影响kimi web的评分apps/kimi-code/dist-web)kimi web用户:只合入本 PR 时 web 仍是旧产物,和新协议对不上groupTurns+foldFacts冷读turn.prompt、legacy 撤销、legacy assistant / tool 消息;隐式结束仍记为 completed)TUI、print 模式、SDK、ACP 和 VS Code 插件都不读转录,不受影响。契约文件里只有
apiSurface快照变化(新增/agents/{agent_id}/turns,删除 4 个 transcript 路由);docs/*-manifest、node-sdk入口、externalHooks、acp-server、apps/kimi-code/src/cli都没动。klient 的promptWithSkills契约本来就带可选promptId,现在引擎会采用它,契约本身没改。受影响的模块与测试(本 PR 新增的测试只保留核心用例;main 上原有的场景按新协议改写后保留):
turn.test.ts累加器报块号;loop.test.ts增量与content.part带块号;eventDispatcher.test.ts带onUndo的 participant 自己处理撤销,回放钩子包住每一次恢复(包括失败的);activateSkill.test.ts打包技能与技能激活采用调用方的 prompt id。services/conversation.test.ts(26 个):折叠规则(条目按步骤和块排序、用户消息的可见文本 / 技能 / 客户端元数据且不含服务端路径、origin 映射、CLI!命令、轮的结局与结束原因、turn_id稳定、思考时长与兜底、插话放在运行中的轮、任务通知、交互与子 agent 关联、工具调用 id 跨轮复用时审批挂到新调用、计划审阅、压缩、分叉的fork_boundary与轮次唯一且有序、无主消息不结束运行中的轮、legacy 撤销与消息),回放结束时收尾悬挂的轮,feed(首次回放失败、重跑回放失败时保留历史、回放与清空上下文推送turns.removed、先发轮再发条目、工具的各个阶段、1 MiB 分页),以及 wire 中损坏的行。conversationContract.e2e.test.ts:由 main 的transcriptContract.e2e.test.ts改写的 10 个场景(S1–S7、S9、S10 和撤销),本 PR 早先额外加的 8 个场景已删除。wsConnectionV1.test.tsack 的 40401 与 40930、agent_ids的订阅与退订;sessionEventBroadcaster.test.tsack 先于内容、每个 feed 只发一页、agent 重建后跟随新的 feed 并报告加载失败;prompts.test.ts、skills.test.ts打包技能与技能激活的prompt_id、没开始轮的 prompt 为failed;sessionRating.test.ts评分不加载已关闭的会话;searchService.test.ts删除 live 路径的用例;sessions.test.tsfeat(agent-core-v2): enforce minimum wire reader version #4638 的不兼容会话用例补上/agents/main/turns和评分返回 40930,以及从 main 移植的"侧边对话的第一个 prompt 早于任何读取时回答不丢";migration-legacyresume.integration.test.ts改用新折叠。pnpm lint(0 error)、pnpm typecheck通过,pnpm test的 5 条失败都在 agent-core-v2 且与本 PR 无关(tool.test.ts与 towerstore.test.ts各一条在本机稳定失败、撤掉本 PR 的改动后同样失败,另外三条在负载下超时、单独重跑通过)。精简测试和第二次合并 main 之后,pnpm typecheck、check-no-comments和提交时的 oxlint 通过,改动过的测试文件全部通过(kap-server 4 个文件 141 条,其中契约测试 10 条;agent-core-v2 3 个文件 116 条)。改成一套表示之后:kap-server 全部 70 个测试文件 1306 条通过,tsc、check-no-comments、oxlint 通过;另用本机约 3,600 份 agent 对话记录(共约 177 万条 wire 记录)分别喂给新旧实现,逐份比较最终的轮,并抽样逐条记录比较最后一轮,差异只有上面说的两类。interaction_id关联,批准后继续;拒绝后工具显示失败;停止运行中的命令后轮为interrupted/user_cancelled;撤销后收到turns.removed,按钮和/undo都按turn_id撤销;刷新后历史一致;每一轮只结束一次;侧边对话以fork_boundary开头,只显示自己的输入。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.