fix(openai): preserve mcp tool call ids

This commit is contained in:
gaoren002
2026-04-24 13:24:21 +00:00
parent e65574dea9
commit 27ee141c1e
2 changed files with 33 additions and 0 deletions

View File

@@ -951,6 +951,7 @@ func isCodexToolCallItemType(typ string) bool {
"local_shell_call", "local_shell_call",
"tool_search_call", "tool_search_call",
"custom_tool_call", "custom_tool_call",
"mcp_tool_call",
"function_call_output", "function_call_output",
"mcp_tool_call_output", "mcp_tool_call_output",
"custom_tool_call_output", "custom_tool_call_output",

View File

@@ -289,6 +289,38 @@ func TestApplyCodexOAuthTransform_PreservesFunctionCallInputName(t *testing.T) {
require.Equal(t, "fc1", item["call_id"]) require.Equal(t, "fc1", item["call_id"])
} }
func TestApplyCodexOAuthTransform_PreservesMCPToolCallIDAndName(t *testing.T) {
reqBody := map[string]any{
"model": "gpt-5.4",
"input": []any{
map[string]any{
"type": "mcp_tool_call",
"call_id": "call_abc",
"name": "remote_tool",
"arguments": "{}",
},
},
}
applyCodexOAuthTransform(reqBody, true, false)
input, ok := reqBody["input"].([]any)
require.True(t, ok)
require.Len(t, input, 1)
item, ok := input[0].(map[string]any)
require.True(t, ok)
require.Equal(t, "mcp_tool_call", item["type"])
require.Equal(t, "remote_tool", item["name"])
require.Equal(t, "fcabc", item["call_id"])
}
func TestCodexInputItemRequiresNameTypesAllowCallID(t *testing.T) {
for _, typ := range []string{"function_call", "custom_tool_call", "mcp_tool_call"} {
require.True(t, codexInputItemRequiresName(typ), typ)
require.True(t, isCodexToolCallItemType(typ), typ)
}
}
func TestApplyCodexOAuthTransform_ExplicitStoreFalsePreserved(t *testing.T) { func TestApplyCodexOAuthTransform_ExplicitStoreFalsePreserved(t *testing.T) {
// 续链场景:显式 store=false 不再强制为 true保持 false。 // 续链场景:显式 store=false 不再强制为 true保持 false。