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
094e1171
Commit
094e1171
authored
Apr 30, 2026
by
shaw
Browse files
fix(openai): infer previous response for item references
parent
733627cf
Changes
4
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
094e1171
...
...
@@ -122,7 +122,7 @@ scripts
.code-review-state
#openspec/
code-reviews/
#
AGENTS.md
AGENTS.md
backend/cmd/server/server
deploy/docker-compose.override.yml
.gocache/
...
...
backend/internal/service/openai_ws_forwarder.go
View file @
094e1171
...
...
@@ -1379,10 +1379,12 @@ func shouldInferIngressFunctionCallOutputPreviousResponseID(
if
signals
.
HasFunctionCallOutputMissingCallID
{
return
false
}
// If the client already sent tool-call context or item_reference anchors,
// treat this as a full replay / self-contained continuation payload rather
// than downgrading it into an inferred delta continuation.
if
signals
.
HasToolCallContext
||
signals
.
HasItemReferenceForAllCallIDs
{
// If the client already sent the actual tool-call context, treat this as
// a full replay / self-contained continuation payload rather than
// downgrading it into an inferred delta continuation. item_reference alone
// is not enough on the store=false WS path: it still needs a valid prior
// response anchor so upstream can resolve the referenced function_call.
if
signals
.
HasToolCallContext
{
return
false
}
return
strings
.
TrimSpace
(
expectedPreviousResponseID
)
!=
""
...
...
backend/internal/service/openai_ws_forwarder_ingress_session_test.go
View file @
094e1171
...
...
@@ -1488,7 +1488,7 @@ func TestOpenAIGatewayService_ProxyResponsesWebSocketFromClient_StoreDisabledFun
require
.
False
(
t
,
gjson
.
Get
(
requestToJSONString
(
captureConn
.
writes
[
1
]),
"previous_response_id"
)
.
Exists
(),
"请求已包含 function_call 上下文时不应自动补齐 previous_response_id"
)
}
func
TestOpenAIGatewayService_ProxyResponsesWebSocketFromClient_StoreDisabledFunctionCallOutput
Skips
AutoAttachWhenItemReferencesPresent
(
t
*
testing
.
T
)
{
func
TestOpenAIGatewayService_ProxyResponsesWebSocketFromClient_StoreDisabledFunctionCallOutputAutoAttachWhen
Only
ItemReferencesPresent
(
t
*
testing
.
T
)
{
gin
.
SetMode
(
gin
.
TestMode
)
cfg
:=
&
config
.
Config
{}
...
...
@@ -1619,7 +1619,7 @@ func TestOpenAIGatewayService_ProxyResponsesWebSocketFromClient_StoreDisabledFun
require
.
Equal
(
t
,
1
,
captureDialer
.
DialCount
())
require
.
Len
(
t
,
captureConn
.
writes
,
2
)
require
.
False
(
t
,
gjson
.
Get
(
requestToJSONString
(
captureConn
.
writes
[
1
]),
"previous_response_id"
)
.
Exists
(),
"请求已包含 item_reference 锚点时不应自动补齐 previous_response_id
"
)
require
.
Equal
(
t
,
"resp_auto_prev_ref_1"
,
gjson
.
Get
(
requestToJSONString
(
captureConn
.
writes
[
1
]),
"previous_response_id"
)
.
String
(),
"仅有 item_reference 不足以自包含 function_call_output,应回填上一轮响应 ID
"
)
}
func
TestOpenAIGatewayService_ProxyResponsesWebSocketFromClient_PreflightPingFailReconnectsBeforeTurn
(
t
*
testing
.
T
)
{
...
...
backend/internal/service/openai_ws_forwarder_ingress_test.go
View file @
094e1171
...
...
@@ -303,12 +303,12 @@ func TestShouldInferIngressFunctionCallOutputPreviousResponseID(t *testing.T) {
want
:
false
,
},
{
name
:
"
skip_when
_item_reference_
already_
covers_
all_
call_ids"
,
name
:
"
infer_when_only
_item_reference_covers_call_ids"
,
storeDisabled
:
true
,
turn
:
2
,
signals
:
ToolContinuationSignals
{
HasFunctionCallOutput
:
true
,
HasItemReferenceForAllCallIDs
:
true
},
expectedPrevious
:
"resp_2"
,
want
:
fals
e
,
want
:
tru
e
,
},
{
name
:
"skip_when_function_call_output_missing_call_id"
,
...
...
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