Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
e70812f0
Unverified
Commit
e70812f0
authored
Apr 13, 2026
by
Wesley Liddick
Committed by
GitHub
Apr 13, 2026
Browse files
Merge pull request #1623 from sakurawztlt/fix/anthropic-buffered-empty-output
fix: anthropic 非流式路径丢失 delta 内容(镜像
b2e379cf
)
parents
ad64190b
a1e299a3
Changes
1
Show whitespace changes
Inline
Side-by-side
backend/internal/service/openai_gateway_messages.go
View file @
e70812f0
...
@@ -270,6 +270,7 @@ func (s *OpenAIGatewayService) handleAnthropicBufferedStreamingResponse(
...
@@ -270,6 +270,7 @@ func (s *OpenAIGatewayService) handleAnthropicBufferedStreamingResponse(
var
finalResponse
*
apicompat
.
ResponsesResponse
var
finalResponse
*
apicompat
.
ResponsesResponse
var
usage
OpenAIUsage
var
usage
OpenAIUsage
acc
:=
apicompat
.
NewBufferedResponseAccumulator
()
for
scanner
.
Scan
()
{
for
scanner
.
Scan
()
{
line
:=
scanner
.
Text
()
line
:=
scanner
.
Text
()
...
@@ -288,8 +289,12 @@ func (s *OpenAIGatewayService) handleAnthropicBufferedStreamingResponse(
...
@@ -288,8 +289,12 @@ func (s *OpenAIGatewayService) handleAnthropicBufferedStreamingResponse(
continue
continue
}
}
// Accumulate delta content for fallback when terminal output is empty.
acc
.
ProcessEvent
(
&
event
)
// Terminal events carry the complete ResponsesResponse with output + usage.
// Terminal events carry the complete ResponsesResponse with output + usage.
if
(
event
.
Type
==
"response.completed"
||
event
.
Type
==
"response.incomplete"
||
event
.
Type
==
"response.failed"
)
&&
if
(
event
.
Type
==
"response.completed"
||
event
.
Type
==
"response.done"
||
event
.
Type
==
"response.incomplete"
||
event
.
Type
==
"response.failed"
)
&&
event
.
Response
!=
nil
{
event
.
Response
!=
nil
{
finalResponse
=
event
.
Response
finalResponse
=
event
.
Response
if
event
.
Response
.
Usage
!=
nil
{
if
event
.
Response
.
Usage
!=
nil
{
...
@@ -318,6 +323,10 @@ func (s *OpenAIGatewayService) handleAnthropicBufferedStreamingResponse(
...
@@ -318,6 +323,10 @@ func (s *OpenAIGatewayService) handleAnthropicBufferedStreamingResponse(
return
nil
,
fmt
.
Errorf
(
"upstream stream ended without terminal event"
)
return
nil
,
fmt
.
Errorf
(
"upstream stream ended without terminal event"
)
}
}
// When the terminal event has an empty output array, reconstruct from
// accumulated delta events so the client receives the full content.
acc
.
SupplementResponseOutput
(
finalResponse
)
anthropicResp
:=
apicompat
.
ResponsesToAnthropic
(
finalResponse
,
originalModel
)
anthropicResp
:=
apicompat
.
ResponsesToAnthropic
(
finalResponse
,
originalModel
)
if
s
.
responseHeaderFilter
!=
nil
{
if
s
.
responseHeaderFilter
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment