Skip to content

Conversation

Copy link

Copilot AI commented Jan 12, 2026

Codex availability checks were using a chat-style request body instead of the OpenAI Responses schema, causing response protocol mismatches.

  • Health check payload: Codex requests now send input: "hi" with max_output_tokens per Responses API instead of messages.
  • Tests: Updated Codex vs. Claude request shape expectations (input/max_output_tokens vs. messages/max_tokens) and kept platform-specific field validation.

Example request body (Codex health check):

{
  "model": "gpt-4o-mini",
  "input": "hi",
  "max_output_tokens": 1
}
Original prompt

目前codex的可用性检测有问题,没有对接好response接口协议,导致了接口响应出现了异常,你应该是查询openai的response协议,然后封装好实现,从而修复这个codex的可用性检测问题


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 12, 2026 15:14
Co-authored-by: lwaay2025 <218015601+lwaay2025@users.noreply.github.com>
Co-authored-by: lwaay2025 <218015601+lwaay2025@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix codex availability check response interface Align Codex health check payload with OpenAI Responses protocol Jan 12, 2026
Copilot AI requested a review from lwaay2025 January 12, 2026 15:18
@lwaay2025
Copy link
Owner

@copilot 你要去确认一下 是否支持max_tokens 目前的传入格式是否是response接口协议的

Copy link
Author

Copilot AI commented Jan 12, 2026

@copilot 你要去确认一下 是否支持max_tokens 目前的传入格式是否是response接口协议的

已对齐 Responses 协议:Codex 健康检查现在发送 input: "hi" 并使用 max_output_tokens(而非 max_tokens),符合 OpenAI Responses API 要求。对应修复提交 808e26b

@lwaay2025 lwaay2025 marked this pull request as ready for review January 12, 2026 15:32
Copilot AI review requested due to automatic review settings January 12, 2026 15:32
@lwaay2025 lwaay2025 merged commit 17181f6 into main Jan 12, 2026
1 check passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a protocol mismatch in Codex health check requests by aligning them with the OpenAI Responses API specification. Previously, health checks were incorrectly sending Chat Completions-style payloads (with messages and implicit max_tokens) to the /responses endpoint, which caused response protocol errors.

Changes:

  • Updated Codex health check payload to use Responses API format: input field with max_output_tokens instead of messages
  • Modified test cases to validate platform-specific request formats (Codex vs. Claude) with separate field expectations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
services/healthcheckservice.go Changed Codex request body from Chat Completions format to Responses API format (input + max_output_tokens)
services/healthcheckservice_test.go Updated test structure to validate Codex-specific fields (input, max_output_tokens) vs Claude fields (messages, max_tokens)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +749 to 755
// Codex Responses 协议
if platform == "codex" {
reqBody := map[string]interface{}{
"model": model,
"messages": []map[string]string{
{"role": "user", "content": "hi"},
},
"model": model,
"input": "hi",
"max_output_tokens": 1,
}
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Codex request format has been updated to use the OpenAI Responses API protocol (input field and max_output_tokens), but the ConnectivityTestService at services/connectivitytestservice.go lines 257-266 still uses the old Chat Completions format (messages field) for /responses endpoints. This inconsistency means health checks and connectivity tests will send different request formats to the same Codex endpoints, which could cause confusion or different behavior between the two services. Consider updating ConnectivityTestService to use the same Responses API format for consistency.

Copilot uses AI. Check for mistakes.
Comment on lines +369 to +381
switch v := reqData["input"].(type) {
case string:
if strings.TrimSpace(v) == "" {
t.Error("input string should not be empty")
}
case []interface{}:
if len(v) == 0 {
t.Error("input array is empty")
return
}
default:
t.Errorf("unexpected input type %T", v)
}
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test accepts both string and array types for the input field (lines 369-381), but the actual implementation at healthcheckservice.go:753 only sends a string ("hi"). The test should be more specific and only expect a string type to match the actual implementation, unless there's a requirement to support array inputs that isn't currently implemented. This flexibility could mask bugs if the implementation accidentally produces an array.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants