Skip to content

fix: grok-420 使用新的 modeId API 格式修复 Super 账号空响应#382

Open
mashiro3000 wants to merge 1 commit intochenyme:mainfrom
mashiro3000:fix/grok-420-modeid
Open

fix: grok-420 使用新的 modeId API 格式修复 Super 账号空响应#382
mashiro3000 wants to merge 1 commit intochenyme:mainfrom
mashiro3000:fix/grok-420-modeid

Conversation

@mashiro3000
Copy link

@mashiro3000 mashiro3000 commented Mar 23, 2026

Summary

修复 grok-4.20-beta(grok-420)模型对 Super 账号返回空响应的问题。grok.com 官方 web 端已将 grok-420 从 modelName/modelMode 格式切换为 modeId 格式,旧的 MODEL_MODE_GROK_420 已被后端标记为 MODEL_MODE_UNKNOWN,导致 sampling engine 连接错误。

Changes

  • app_chat.py: grok-420 模型使用 modeId 替代 modelName/modelMode,移除旧字段并设置 responseMetadata 为空(与官方 web 端抓包一致)
  • model.py: grok-4.20-beta 改用 MODEL_MODE_EXPERT(多 Agent 深度思考)
  • model.py: 新增 grok-4.20-fast 模型(MODEL_MODE_FAST,快速回答)

Verification

  • modeId=expert: 4 Agent 并行思考 + 真实内容输出
  • modeId=fast: 直接回答,无思考过程
  • 其他模型(grok-4、grok-3、grok-4.1-fast 等)不受影响
  • 流式和非流式均正常
  • 多台服务器部署测试通过

Closes #339

grok.com 官方 web 端已将 grok-420 模型从 modelName/modelMode 格式
切换为 modeId 格式,旧的 MODEL_MODE_GROK_420 已被后端标记为
MODEL_MODE_UNKNOWN 并返回 sampling engine 连接错误。

变更内容:
- app_chat.py: grok-420 模型使用 modeId 替代 modelName/modelMode,
  移除旧字段并设置 responseMetadata 为空(与官方 web 端一致)
- model.py: grok-4.20-beta 改用 MODEL_MODE_EXPERT(多 Agent 深度思考),
  新增 grok-4.20-fast 模型(MODEL_MODE_FAST,快速回答)

测试验证:
- modeId=expert: 4 Agent 并行思考 + 真实内容输出
- modeId=fast: 直接回答,无思考过程
- 其他模型(grok-4、grok-3 等)不受影响

Closes chenyme#339
Copilot AI review requested due to automatic review settings March 23, 2026 05:42
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

该 PR 旨在修复 grok-4.20-beta(底层 grok-420)在 Super 账号下出现空响应的问题,通过对齐 grok.com web 端已切换的新请求字段格式(modeId)。

Changes:

  • grok-420 请求在 app-chat payload 中改用 modeId(并移除 modelName/modelMode),同时设置 enable420
  • grok-4.20-betamodel_mode 调整为 MODEL_MODE_EXPERT,并将其 cost 调整为 HIGH。
  • 新增 grok-4.20-fast 模型(MODEL_MODE_FAST)。

Reviewed changes

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

File Description
app/services/reverse/app_chat.py grok-420 构造新格式 payload:使用 modeId 替代旧字段,并调整 responseMetadata 行为
app/services/grok/services/model.py 更新 grok-4.20-beta 的 mode/cost,并新增 grok-4.20-fast 模型条目

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

Comment on lines +124 to +128
# grok-420: 使用新的 modeId 格式,移除旧的 modelName/modelMode
payload.pop("modelName", None)
payload.pop("modelMode", None)
payload["responseMetadata"] = {}
payload["modeId"] = _GROK420_MODE_ID_MAP.get(mode, "expert")
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

For grok-420 you set payload["responseMetadata"] = {} to match the new request format, but later model_config_override is always written into payload["responseMetadata"]["modelConfigOverride"] when provided (e.g., OpenAI-compatible requests always pass temperature/topP). This means responseMetadata is not actually empty for grok-420. If the upstream API requires an empty responseMetadata for grok-420, consider skipping/moving this override for that model; otherwise please align the inline comment/PR description with the actual behavior.

Copilot uses AI. Check for mistakes.
model_mode="MODEL_MODE_EXPERT",
tier=Tier.BASIC,
cost=Cost.LOW,
cost=Cost.HIGH,
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

grok-4.20-beta is being changed from low-cost to high-cost (cost=Cost.HIGH), which affects usage accounting (effort) and may change the “计次/Cost” users expect. Please update the model tables in readme.md / docs/README.en.md so user-facing docs match runtime behavior.

Suggested change
cost=Cost.HIGH,
cost=Cost.LOW,

Copilot uses AI. Check for mistakes.
Comment on lines +167 to 177
model_id="grok-4.20-fast",
grok_model="grok-420",
model_mode="MODEL_MODE_FAST",
tier=Tier.BASIC,
cost=Cost.LOW,
display_name="GROK-4.20-FAST",
is_image=False,
is_image_edit=False,
is_video=False,
),
ModelInfo(
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

A new model id grok-4.20-fast is added here. Please also add it to the user-facing model list (readme.md / docs/README.en.md) so API consumers can discover and select it intentionally.

Suggested change
model_id="grok-4.20-fast",
grok_model="grok-420",
model_mode="MODEL_MODE_FAST",
tier=Tier.BASIC,
cost=Cost.LOW,
display_name="GROK-4.20-FAST",
is_image=False,
is_image_edit=False,
is_video=False,
),
ModelInfo(

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.

question: 目前使用surper账号也无法使用4.20

2 participants