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
3f8c8d70
Unverified
Commit
3f8c8d70
authored
Jan 14, 2026
by
Wesley Liddick
Committed by
GitHub
Jan 14, 2026
Browse files
Merge pull request #274 from mt21625457/main
fix(openai): OAuth 请求强制 store=false
parents
55fced39
9c567fad
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/internal/service/openai_codex_transform.go
View file @
3f8c8d70
...
@@ -90,17 +90,11 @@ func applyCodexOAuthTransform(reqBody map[string]any) codexTransformResult {
...
@@ -90,17 +90,11 @@ func applyCodexOAuthTransform(reqBody map[string]any) codexTransformResult {
result
.
NormalizedModel
=
normalizedModel
result
.
NormalizedModel
=
normalizedModel
}
}
// 续链场景强制启用 store;非续链仍按原策略强制关闭存储。
// OAuth 走 ChatGPT internal API 时,store 必须为 false;显式 true 也会强制覆盖。
if
needsToolContinuation
{
// 避免上游返回 "Store must be set to false"。
if
v
,
ok
:=
reqBody
[
"store"
]
.
(
bool
);
!
ok
||
!
v
{
if
v
,
ok
:=
reqBody
[
"store"
]
.
(
bool
);
!
ok
||
v
{
reqBody
[
"store"
]
=
true
reqBody
[
"store"
]
=
false
result
.
Modified
=
true
result
.
Modified
=
true
}
}
else
{
if
v
,
ok
:=
reqBody
[
"store"
]
.
(
bool
);
!
ok
||
v
{
reqBody
[
"store"
]
=
false
result
.
Modified
=
true
}
}
}
if
v
,
ok
:=
reqBody
[
"stream"
]
.
(
bool
);
!
ok
||
!
v
{
if
v
,
ok
:=
reqBody
[
"stream"
]
.
(
bool
);
!
ok
||
!
v
{
reqBody
[
"stream"
]
=
true
reqBody
[
"stream"
]
=
true
...
...
backend/internal/service/openai_codex_transform_test.go
View file @
3f8c8d70
...
@@ -11,7 +11,7 @@ import (
...
@@ -11,7 +11,7 @@ import (
)
)
func
TestApplyCodexOAuthTransform_ToolContinuationPreservesInput
(
t
*
testing
.
T
)
{
func
TestApplyCodexOAuthTransform_ToolContinuationPreservesInput
(
t
*
testing
.
T
)
{
// 续链场景:保留 item_reference 与 id,
并启用 stor
e。
// 续链场景:保留 item_reference 与 id,
但不再强制 store=tru
e。
setupCodexCache
(
t
)
setupCodexCache
(
t
)
reqBody
:=
map
[
string
]
any
{
reqBody
:=
map
[
string
]
any
{
...
@@ -25,9 +25,10 @@ func TestApplyCodexOAuthTransform_ToolContinuationPreservesInput(t *testing.T) {
...
@@ -25,9 +25,10 @@ func TestApplyCodexOAuthTransform_ToolContinuationPreservesInput(t *testing.T) {
applyCodexOAuthTransform
(
reqBody
)
applyCodexOAuthTransform
(
reqBody
)
// 未显式设置 store=true,默认为 false。
store
,
ok
:=
reqBody
[
"store"
]
.
(
bool
)
store
,
ok
:=
reqBody
[
"store"
]
.
(
bool
)
require
.
True
(
t
,
ok
)
require
.
True
(
t
,
ok
)
require
.
Tru
e
(
t
,
store
)
require
.
Fals
e
(
t
,
store
)
input
,
ok
:=
reqBody
[
"input"
]
.
([]
any
)
input
,
ok
:=
reqBody
[
"input"
]
.
([]
any
)
require
.
True
(
t
,
ok
)
require
.
True
(
t
,
ok
)
...
@@ -45,8 +46,8 @@ func TestApplyCodexOAuthTransform_ToolContinuationPreservesInput(t *testing.T) {
...
@@ -45,8 +46,8 @@ func TestApplyCodexOAuthTransform_ToolContinuationPreservesInput(t *testing.T) {
require
.
Equal
(
t
,
"o1"
,
second
[
"id"
])
require
.
Equal
(
t
,
"o1"
,
second
[
"id"
])
}
}
func
TestApplyCodexOAuthTransform_
ToolContinuationForcesStoreTrue
(
t
*
testing
.
T
)
{
func
TestApplyCodexOAuthTransform_
ExplicitStoreFalsePreserved
(
t
*
testing
.
T
)
{
// 续链场景:显式 store=false
也会被
强制为 true。
// 续链场景:显式 store=false
不再
强制为 true
,保持 false
。
setupCodexCache
(
t
)
setupCodexCache
(
t
)
reqBody
:=
map
[
string
]
any
{
reqBody
:=
map
[
string
]
any
{
...
@@ -62,16 +63,35 @@ func TestApplyCodexOAuthTransform_ToolContinuationForcesStoreTrue(t *testing.T)
...
@@ -62,16 +63,35 @@ func TestApplyCodexOAuthTransform_ToolContinuationForcesStoreTrue(t *testing.T)
store
,
ok
:=
reqBody
[
"store"
]
.
(
bool
)
store
,
ok
:=
reqBody
[
"store"
]
.
(
bool
)
require
.
True
(
t
,
ok
)
require
.
True
(
t
,
ok
)
require
.
Tru
e
(
t
,
store
)
require
.
Fals
e
(
t
,
store
)
}
}
func
TestApplyCodexOAuthTransform_
NonContinuationForcesStoreFalseAndStripsIDs
(
t
*
testing
.
T
)
{
func
TestApplyCodexOAuthTransform_
ExplicitStoreTrueForcedFalse
(
t
*
testing
.
T
)
{
//
非续链场景:强制 store=false,并移除 input 中的 id
。
//
显式 store=true 也会强制为 false
。
setupCodexCache
(
t
)
setupCodexCache
(
t
)
reqBody
:=
map
[
string
]
any
{
reqBody
:=
map
[
string
]
any
{
"model"
:
"gpt-5.1"
,
"model"
:
"gpt-5.1"
,
"store"
:
true
,
"store"
:
true
,
"input"
:
[]
any
{
map
[
string
]
any
{
"type"
:
"function_call_output"
,
"call_id"
:
"call_1"
},
},
"tool_choice"
:
"auto"
,
}
applyCodexOAuthTransform
(
reqBody
)
store
,
ok
:=
reqBody
[
"store"
]
.
(
bool
)
require
.
True
(
t
,
ok
)
require
.
False
(
t
,
store
)
}
func
TestApplyCodexOAuthTransform_NonContinuationDefaultsStoreFalseAndStripsIDs
(
t
*
testing
.
T
)
{
// 非续链场景:未设置 store 时默认 false,并移除 input 中的 id。
setupCodexCache
(
t
)
reqBody
:=
map
[
string
]
any
{
"model"
:
"gpt-5.1"
,
"input"
:
[]
any
{
"input"
:
[]
any
{
map
[
string
]
any
{
"type"
:
"text"
,
"id"
:
"t1"
,
"text"
:
"hi"
},
map
[
string
]
any
{
"type"
:
"text"
,
"id"
:
"t1"
,
"text"
:
"hi"
},
},
},
...
...
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