Skip to content

Conversation

@DeJeune
Copy link
Collaborator

@DeJeune DeJeune commented Nov 30, 2025

What this PR does

image

点击生成后

image

这个PR的主要作用是向用户清晰展示,某个请求被“截断”的原因,方便排查是服务端还是客户端的问题

推理模型的继续生成效果不太好

Before this PR:

  • Cherry Studio did not properly handle finish reasons from AI SDK streams
  • Message continuation behavior was incomplete
  • Warning conditions for finish reason handling were overly complex

After this PR:

  • Added comprehensive support for message continuation and finish reason handling in the AI SDK to Chunk adapter
  • Improved the warning logic to be more intuitive and less noisy
  • Enhanced the streaming response processing to better handle various completion scenarios

Why we need it and why it was done in this way

This feature is needed to properly handle streaming responses from AI providers that may finish for various reasons (length, content filtering, stop sequences, etc.). Without proper finish reason handling, users may not understand why their AI responses ended unexpectedly.

The implementation was done in the AiSdkToChunkAdapter because it is the central component responsible for converting AI SDK streams into Cherry Studio's internal chunk format. This ensures consistent behavior across all AI providers that use the AI SDK integration.

The following tradeoffs were made:

  • Simplified the warning condition logic to reduce false positives
  • Added new state tracking for first text content detection
  • Maintained backward compatibility with existing chunk processing

The following alternatives were considered:

  • Handling finish reasons at the provider level: This would lead to inconsistent behavior across providers
  • Adding a separate finish reason processor: This would increase complexity without clear benefits

Links to places where the discussion took place:

Breaking changes

This PR does not introduce breaking changes. All existing functionality remains intact, with only additions to the streaming response handling.

Special notes for your reviewer

The main changes are in:

  • src/renderer/src/aiCore/chunk/AiSdkToChunkAdapter.ts: Core logic for finish reason handling
  • Multiple locale files: Added i18n support for the new warning messages

Please pay special attention to the simplified warning condition that only triggers when there is text content but no finish reason.

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note

Improved streaming response handling with proper finish reason detection and message continuation support. Added warning system for incomplete responses and enhanced AI SDK integration.

@DeJeune DeJeune requested a review from 0xfullex as a code owner November 30, 2025 18:39
@0xfullex 0xfullex added the Blocked: v2 The PR is blocked until v2 released label Dec 3, 2025
@0xfullex
Copy link
Collaborator

0xfullex commented Dec 3, 2025

Note

This issue/comment/review was translated by Claude.

Since the message core process is being refactored in v2, this PR is temporarily blocked.


Original Content 由于message核心流程正在v2中重构,该PR暂时blocked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Blocked: v2 The PR is blocked until v2 released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants