MUL-5657 fix(agent): add missing streamingCurrentTurn gate to kimi ACP backend - #6308
Conversation
kimi.go was the only ACP backend missing the streamingCurrentTurn gate. Without it, history replay emitted by the Kimi CLI during session/resume contaminates Result.Output and the message stream with previous-turn content — the user sees the old answer duplicated alongside the new one. The root cause is chronological: the gate was introduced for Hermes in PR multica-ai#2024 (2026-05-03) but kimi already existed at that point and was not updated. Later backends (grok, traecli) were written after the fix and included the gate from day one. Add the same atomic.Bool gate + acceptNotification callback pattern used by hermes, grok, traecli, kiro, and qoder. Pin with TestKimiBackendDropsHistoryReplayOnResume.
|
@liuguiyuan3 is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks a lot for this — and welcome! This is an unusually well-researched first contribution. Two things stood out. First, the root cause writeup: identifying that the gate landed in #2024 for hermes while kimi already existed and simply never got patched explains why this backend was the odd one out, which is far more useful than just describing the symptom. Second, you verified the new test fails without the fix. That's the step that separates a real regression guard from an assertion that happens to be true — please keep doing it. We independently confirmed the behaviour on our side:
Merging as-is. Two follow-ups we'll pick up separately, neither of which needs anything from you:
Thanks again. |
Co-authored-by: multica-agent <github@multica.ai>
…6311) * docs(changelog): add v0.4.17 release entry (2026-08-03) (MUL-5655) Co-authored-by: multica-agent <github@multica.ai> * docs(changelog): drop the MCP allowlist fix, reverted in #6314 (MUL-5655) Co-authored-by: multica-agent <github@multica.ai> * docs(changelog): add the Kimi resume fix from #6308 (MUL-5655) Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: Eve <eve@multica-ai.local> Co-authored-by: multica-agent <github@multica.ai>
Summary
streamingCurrentTurngate to kimi backend, matching hermes/grok/traecli/kiro/qoderTestKimiBackendDropsHistoryReplayOnResumeregression testProblem
When a Kimi session is resumed (
session/resume), the ACP runtime replays prior-turn transcripts assession/updatenotifications before the client sendssession/prompt. All other ACP backends gate these notifications with astreamingCurrentTurnatomic.Bool that is only flipped totrueaftersession/promptis sent — but kimi.go was missing this gate entirely.The result: on resume, the previous answer is duplicated into
Result.Outputand streamed to the UI alongside the new answer.Root Cause
The gate was introduced in PR #2024 (2026-05-03) for hermes only. Kimi already existed at that time but was not patched. Subsequent backends (grok #5285, traecli #4724) were written after the fix and included the gate from the start.
Fix
Add the identical gate pattern (6 touch points):
var streamingCurrentTurn atomic.BoolacceptNotificationcallback →return streamingCurrentTurn.Load()onMessagegate →if !streamingCurrentTurn.Load() { return }onPromptDonegate →if !streamingCurrentTurn.Load() { return }streamingCurrentTurn.Store(true)beforesession/promptstreamingCurrentTurn.Store(false)after drainTest plan
go build ./...passesgo test ./pkg/agent/ -run TestKimi -count=1— all 7 kimi tests pass (including new one)