Skip to content

fix: prioritize content over reasoning_content when both are in same SSE delta - #46

Merged
ace331 merged 1 commit into
mainfrom
fix/minimax-thinking-disable
Jul 27, 2026
Merged

ace331 merged 1 commit into
mainfrom
fix/minimax-thinking-disable

Conversation

@fgclaw01

Copy link
Copy Markdown
Collaborator

Problem

kimi-k2.7-code through realapi-aliyun sends SSE chunks where both content and reasoning_content are non-empty in the same delta:

{"delta":{"content":"你好!很高兴见到你。有什么我可以帮",
           "reasoning_content":" them and asking how I can help."}}

parse_sse_chunk checked reasoning_content first and returned early, silently dropping the visible text content. The user saw only fragments like "你的吗?" instead of the full response.

Fix

Swap the check order: content before reasoning_content. The reasoning tail fragment in the mixed chunk is lost (typically just the last few words already captured in earlier chunks), but visible text is never dropped.

Verification

Python simulation against live realapi-aliyun API:

  • Before: Content = '' (dropped entirely) or '你的吗?' (fragment)
  • After: Content = '你好!很高兴见到你,有什么我可以帮你的吗?' ✅

Changes

  • agent/src/llm/helpers.rs: swap content check before reasoning_content check in parse_sse_chunk
  • Add regression test content_before_reasoning_when_both_present

…SSE delta

kimi-k2.7-code through realapi-aliyun sends SSE chunks where both
'content' and 'reasoning_content' are non-empty in the same delta.
parse_sse_chunk checked reasoning_content first and returned early,
silently dropping the visible text content — the user saw only
fragments like '你的吗?' instead of the full response.

Fix: check content BEFORE reasoning_content so visible text is
never dropped. The reasoning tail fragment in the mixed chunk is
lost, which is acceptable since it's typically just the last few
words of a sentence already captured in earlier chunks.
@fgclaw01
fgclaw01 force-pushed the fix/minimax-thinking-disable branch from 6baa2ef to 63c7bdb Compare July 27, 2026 02:31
@ace331
ace331 merged commit 49f650d into main Jul 27, 2026
16 checks passed
@ace331
ace331 deleted the fix/minimax-thinking-disable branch July 27, 2026 02:36
@fgclaw01
fgclaw01 restored the fix/minimax-thinking-disable branch July 27, 2026 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants