Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pkg/llminterface/anthropic/anthropic.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ func (a *AnthropicAdapter) Chat(ctx context.Context, input llminterface.ChatInpu
},
}
outputChan <- chunk

case anthropic.ThinkingDelta:
chunk := llminterface.ChatOutputChunk{
Reasoning: Some(deltaVariant.JSON.Thinking.Raw()),
}
outputChan <- chunk
case anthropic.InputJSONDelta:
// 工具调用参数增量
currentToolArgs.WriteString(deltaVariant.PartialJSON)
Expand Down Expand Up @@ -190,7 +194,11 @@ func (a *AnthropicAdapter) Chat(ctx context.Context, input llminterface.ChatInpu
chunk := llminterface.ChatOutputChunk{
Error: stream.Err(),
}
outputChan <- chunk

// 只有当有实际内容时才发送 chunk
if len(chunk.ContentParts) > 0 || chunk.Reasoning.IsSome() {
outputChan <- chunk
}
Comment on lines +198 to +201
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The conditional check if len(chunk.ContentParts) > 0 || chunk.Reasoning.IsSome() prevents stream errors from being propagated. Since chunk.ContentParts is empty and chunk.Reasoning is None when an error occurs, the error chunk is never sent, silently ignoring the error. Revert to unconditionally sending the error chunk to ensure proper error propagation.

Suggested change
// 只有当有实际内容时才发送 chunk
if len(chunk.ContentParts) > 0 || chunk.Reasoning.IsSome() {
outputChan <- chunk
}
outputChan <- chunk

}
}()

Expand Down