sub2api icon indicating copy to clipboard operation
sub2api copied to clipboard

[Regression] v0.1.157+: OpenCode Go Chat Completions-only accounts are filtered from ordinary Codex Responses requests

Open xboluo18 opened this issue 4 months ago • 1 comments

问题概述

从 v0.1.157 开始,使用 OpenCode Go API Key 的 OpenAI-compatible 账号无法承接 Codex 的普通文本 POST /v1/responses 请求。

上游 /v1/chat/completions 正常,Sub2API 管理端账号测试也成功;但经过网关时,请求在账号选择阶段直接返回 503,没有发送到上游。

本报告是 #4449 的具体生产影响案例,并补充首次受影响版本是 v0.1.157+,不只是 v0.1.158。服务器、账号 ID、下游 Key、IP 和 request_id 均已匿名化。

环境

  • Sub2API: v0.1.157
  • 客户端: Codex
  • 入站端点: POST /v1/responses
  • 分组平台: OpenAI
  • 账号类型: OpenAI-compatible APIKey
  • 上游: OpenCode Go
  • Base URL: https://opencode.ai/zen/go/v1
  • 探测结果: openai_responses_supported=false
  • 上游原生接口: /v1/chat/completions
  • 示例模型: glm-5.2、qwen3.7-max、minimax-m3

已验证事实

  1. OpenCode Go API Key 有效。
  2. 直接请求 OpenCode Go /v1/chat/completions 正常。
  3. Sub2API 管理端账号测试可成功调用 glm-5.2。
  4. 账号 active=true、schedulable=true,模型映射和分组归属正确。
  5. Codex 请求相关模型时,在账号选择阶段返回 no available accounts,没有 account_id 或 upstream_status。

典型日志

content_moderation.gateway_check_done
allowed=true
blocked=false

openai.account_select_failed
model=glm-5.2
stream=true
error="no available accounts"
excluded_account_count=0

qwen3.7-max、minimax-m3 等仅由该 Chat Completions 上游提供的模型表现相同。

最小复现配置

{
  "base_url": "https://opencode.ai/zen/go/v1",
  "model_mapping": {
    "glm-5.2": "glm-5.2"
  },
  "openai_responses_supported": false
}

普通文本 Codex Responses 请求会被动声明 image_gen namespace,即使用户没有请求生图:

{
  "model": "glm-5.2",
  "input": "Reply with exactly OK",
  "stream": true,
  "tools": [
    {
      "type": "namespace",
      "name": "image_gen",
      "tools": [
        {
          "type": "function",
          "name": "imagegen"
        }
      ]
    }
  ],
  "tool_choice": "auto"
}

实际结果:

HTTP 503
openai.account_select_failed
error="no available accounts"
excluded_account_count=0

对照实验:

  • 直接请求上游 /v1/chat/completions:成功。
  • 管理端账号测试:成功。
  • 移除被动 image_gen namespace,或使用旧版调度路径:可以选中账号。

回归版本边界

引入 Responses capability 调度门控的提交:

605b026c fix(gateway): route image-intent /v1/responses only to Responses-capable accounts (#4417)

该提交包含在 v0.1.157 中,不包含在 v0.1.155 中。生产环境回滚到 v0.1.157 后问题仍然存在。

根因判断

普通 Codex 文本请求的被动 image_gen namespace 在 PlatformOpenAI 路径被识别为 imageIntent=true,随后调度器强制 requiredCapability=Responses。

OpenCode Go 已探测为 openai_responses_supported=false,因此账号在请求发送上游前被过滤。

这不是 API Key、Base URL、模型映射、账号状态、分组权限或上游网络问题。

期望行为

仅被动声明 image_gen namespace 且 tool_choice=auto 的普通文本请求,应允许调度到 Chat Completions-only 账号,并沿现有 Responses -> Chat Completions bridge 转发。

只有明确生图信号才应强制要求原生 Responses 能力,例如图片模型、原生 image_generation 工具、明确选择图片工具或已有真实图片工具调用。

建议

  1. 区分被动 namespace catalog 与真实生图意图。
  2. 增加 OpenCode Go / Chat Completions-only APIKey 回归测试。
  3. 将影响版本标记为 v0.1.157+。
  4. 修复前在后台提示 Codex 被动图片工具声明会使 Chat Completions-only 账号不可调度。

Related: #4449

xboluo18 avatar Jul 17 '26 05:07 xboluo18

在 HEAD (b8dece9, v0.2.13) 上核对,能力路由这条路径看起来已经被后续提交修掉了:

  • internal/handler/openai_gateway_handler.go 的三个相关位置(约 553、2483、2682 行)都用的是 service.IsExplicitImageGenerationIntent,它明确排除被动的 image_gen namespace 声明。
  • internal/handler/gateway_handler_responses.go:103 仍在用 IsImageGenerationIntentForPlatform,但它只用于设置 token 计费上下文(WithOpenAIImageGenerationIntent),不再参与账号能力过滤。
  • IsExplicitImageGenerationIntent 的注释直接点名了 #4476。

麻烦在最新版本上再确认一次是否仍能复现(OpenCode Go + openai_responses_supported=false + 被动 image_gen namespace 的普通文本请求)。若仍复现,请附上新版本的 openai.account_select_failed 日志,可以继续跟进是哪个调用点漏了。

hzh6767 avatar Oct 05 '26 03:10 hzh6767