File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -218,6 +218,7 @@ function handleContent(
218218 delta . content === ""
219219 && delta . reasoning_opaque
220220 && delta . reasoning_opaque . length > 0
221+ && state . thinkingBlockOpen
221222 ) {
222223 events . push (
223224 {
@@ -317,6 +318,15 @@ function handleThinkingText(
317318 events : Array < AnthropicStreamEventData > ,
318319) {
319320 if ( delta . reasoning_text && delta . reasoning_text . length > 0 ) {
321+ // compatible with copilot API returning content->reasoning_text->reasoning_opaque in different deltas
322+ // this is an extremely abnormal situation, probably a server-side bug
323+ // only occurs in the claude model, with a very low probability of occurrence
324+ if ( state . contentBlockOpen ) {
325+ delta . content = delta . reasoning_text
326+ delta . reasoning_text = undefined
327+ return
328+ }
329+
320330 if ( ! state . thinkingBlockOpen ) {
321331 events . push ( {
322332 type : "content_block_start" ,
You can’t perform that action at this time.
0 commit comments