Repository navigation
fix(kap-server): end streamed items once from the recorded step - #4730
Conversation
The feed ended a streaming reasoning or message item as soon as the next block of its step started, filling duration_ms from its own clock, and the persisted item then ended it again with the engine's duration. Streamed items now stay running until the step is recorded and end once.
🦋 Changeset detectedLatest commit: 06b9601 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: 49d536790f
ℹ️ 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".
dd57666 to
5954456
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
…th 2.6.0 MoonshotAI#4772: end tool calls cut short by a stop as interrupted, and keep a tool error failed when the step itself failed. MoonshotAI#4826: drop the deprecated turn_id alias from the file-history queries; a turn_id-only query now fails validation with 40001. MoonshotAI#4730: a streamed item no longer ends early from the feed clock. The source shape is in place; the remaining live-feed gap is recorded in the ledger row.
…hotAI#4755 evidence MoonshotAI#4618 is configured through [transcript].tool_call_density and [transcript].thinking, not a [transcript.group] table. The MoonshotAI#4618 probe limitation and the four-file hang noted on MoonshotAI#4755 were fixed in 580b5b5 and 4d88e05. MoonshotAI#4730 was recorded as no longer reconstructing step ids, which the step.begin case still does; the real gap was the live context-memory fold dropping the recorded content-part timing, now fixed in 008fb38. Verdicts are unchanged.
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
每个流式产生的思考条目会收到两次
item.ended,两次只差duration_ms。界面上的思考时长会在这一步结束时跳一下(例如 4.2s 变 4.1s),而且每个思考块多一帧。Bug Reproduction Steps
…:0在回复开始时收到一次item.ended(duration_ms为 feed 自己算的值),这一步落盘后又收到一次(duration_ms为引擎记录的值)。Root Cause
feed 的
endLiveBlocks在同一步里下一段文本、思考或工具调用开始时,把前面运行中的条目立即标成结束,并用 feed 自己的时钟填duration_ms(从收到第一个增量到下一段开始)。引擎落盘的content.part记的是这一块第一个增量到最后一个增量。两个口径不同,差分发现不一致,就以落盘值再发一次item.ended。这是根本修复:时长只由引擎决定,feed 不再自己估算。Code Changes
onTextDelta / onToolCallDelta new block of the step - endLiveBlocks(step) # end earlier running items with the feed's own duration item.started step persisted (content.part) fold writes the authoritative item item.ended # now the only one, with the engine's duration_ms删除
endLiveBlocks和它的两处调用,以及只为它存在的LiveItem.startedAt。流式条目保持running,等这一步落盘后由折叠产生的正式条目发唯一一次item.ended。中英文server-api.md里对应的说明同步改了。Behavior Changes and Affected Users
item.ended”当作“这一段输出完毕”的外部客户端streamingTailIndex),回复开始后思考块照样显示为“思考过程”并停止计时,这部分不变。services/conversation.test.ts新增「ends a streamed item once, from the recorded step, with the duration the engine measured」:先思考再回答,流式期间不发item.ended,落盘后思考条目只结束一次且duration_ms为引擎的值;用 main 的实现该用例失败。kap-server 全部测试通过。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.