Skip to content

[Provider compatibility] Qwen models fail through Responses → Chat translation: "System message must be at the beginning" #6242

Closed

Description

@K9ineX3D

Client or integration

Codex CLI

Area

Provider adapter

Summary

Qwen models cannot be used through OpenCodex when routed from the Codex CLI.

The upstream provider returns HTTP 502 with:

upstream_server_error
System message must be at the beginning.

The OpenCodex log shows that the request is being processed through the translated protocol path:

Client API: Responses
Delivery mode: Translated
Upstream API: Chat
Request path: Responses → IR → Chat
Response path: Chat → IR → Responses

This appears to indicate that the Responses → IR → Chat translation is producing a Chat Completions message sequence where the system message is not the first message.

Importantly, the same Qwen model works when called directly against the provider without going through OpenCodex, so the model/provider itself appears functional.

Reproduction

  1. Configure OpenCodex with the AMD or any provider and with a Qwen model.
  2. Start OpenCodex and use the model through Codex CLI.
  3. Send a normal prompt.
  4. The request fails with HTTP 502.

Observed error:

System message must be at the beginning.

The OpenCodex log identifies the selected route as:

AMD/Qwen3.8-27B — explicit-provider-namespace

and the protocol path as:

Responses → IR → Chat
  1. Call the same Qwen model directly against the provider, bypassing OpenCodex.
  2. The direct request succeeds.

Version

2.71.0

Operating system

Kali GNU/Linux 2026.3

Provider and model

No response

Logs or error output

HTTP 502 Bad upstream response

Failure cause:
Upstream fault (reached: protocol prelude)

Upstream reason:
System message must be at the beginning.

Provider:
AMD

Model:
Qwen3.8-27B

Protocol:
Responses → IR → Chat



{
  "requestId": "ocx-da488b5f94e4984c782d743f096f9993",
  "timestamp": 1790691239442,
  "model": "Qwen3.8-27B",
  "provider": "AMD",
  "admissionKind": "loopback",
  "inboundProtocol": "responses",
  "accountLogLabel": "kb697860e8b4c1dd0df9938d2160aeca1",
  "conversationId": "d17ab8bcfdcd3a437fa74a3f441ea61b",
  "requestedModel": "AMD/Qwen3.8-27B",
  "requestedAlias": "AMD/Qwen3.8-27B",
  "requestedEffort": "xhigh",
  "effectiveEffort": "xhigh",
  "reasoningWireField": "reasoning_effort",
  "reasoningWireValue": "xhigh",
  "configuredServiceTier": "fast",
  "configuredSpeedLabel": "fast",
  "modelSupportsServiceTier": false,
  "tierOutcome": {
    "wireKind": null,
    "wireValue": null,
    "fastOutcome": "unknown",
    "confirmation": "unknown"
  },
  "resolvedModel": "Qwen3.8-27B",
  "servedModel": "Qwen3.8-27B",
  "status": 502,
  "durationMs": 2385,
  "errorCode": "upstream_server_error",
  "terminalStatus": "failed",
  "closeReason": "terminal",
  "upstreamError": "System message must be at the beginning.",
  "usageStatus": "unreported",
  "attempts": [
    {
      "ordinal": 1,
      "provider": "AMD",
      "model": "Qwen3.8-27B",
      "adapter": "openai-chat",
      "status": 502,
      "durationMs": 2372,
      "sendCount": 1,
      "recoveryKinds": [],
      "usageStatus": "unreported",
      "requestedEffort": "xhigh",
      "effectiveEffort": "xhigh",
      "reasoningWireField": "reasoning_effort",
      "reasoningWireValue": "xhigh",
      "tierOutcome": {
        "wireKind": null,
        "wireValue": null,
        "fastOutcome": "unknown",
        "confirmation": "unknown"
      },
      "accountLogLabel": "kb697860e8b4c1dd0df9938d2160aeca1",
      "deliverySummary": {
        "adapterEvents": 1,
        "relayedEvents": 3,
        "semanticBytes": 0,
        "sideEffectEvents": 0,
        "terminalEvents": 1
      },
      "errorCode": "upstream_server_error",
      "failureStage": "protocol-prelude",
      "failureCause": "upstream-fault",
      "resendPermission": "refused-ambiguous",
      "displayMetrics": {
        "tokPerSecond": {
          "kind": "unavailable",
          "reason": "usage_missing"
        },
        "decodeTokPerSecond": {
          "kind": "unavailable",
          "reason": "usage_missing"
        },
        "cost": {
          "kind": "unavailable",
          "reason": "usage_missing"
        }
      }
    }
  ],
  "spend": {
    "sends": 1,
    "settled": 1,
    "unresolved": 0
  },
  "transportPhase": "terminal_sse",
  "terminalSource": "upstream",
  "routeDecision": {
    "version": 1,
    "decisionId": "278cb2b49b0c",
    "createdAt": 1790691239454,
    "requestedModel": "AMD/Qwen3.8-27B",
    "routeKind": "explicit-provider",
    "requirements": [],
    "candidates": [
      {
        "provider": "AMD",
        "model": "Qwen3.8-27B",
        "eligible": true,
        "exclusions": []
      }
    ],
    "selected": {
      "candidateIndex": 0,
      "provider": "AMD",
      "model": "Qwen3.8-27B",
      "reason": "explicit-provider-namespace"
    }
  },
  "protocolTrace": {
    "v": 1,
    "inbound": "responses",
    "mode": "translated",
    "upstream": "chat",
    "requestPath": [
      "responses",
      "ir",
      "chat"
    ],
    "responsePath": [
      "chat",
      "ir",
      "responses"
    ],
    "reasonCodes": [
      "cross-wire-ir"
    ],
    "attempts": [
      {
        "ordinal": 1,
        "upstream": "chat",
        "mode": "translated",
        "requestPath": [
          "responses",
          "ir",
          "chat"
        ]
      }
    ],
    "contractVersion": "2026-09-25.2"
  },
  "failureStage": "protocol-prelude",
  "failureCause": "upstream-fault",
  "resendPermission": "refused-ambiguous",
  "displayMetrics": {
    "tokPerSecond": {
      "kind": "unavailable",
      "reason": "usage_missing"
    },
    "decodeTokPerSecond": {
      "kind": "unavailable",
      "reason": "usage_missing"
    },
    "cost": {
      "kind": "unavailable",
      "reason": "combo_attempt_unavailable"
    }
  }
}

Screenshots and supporting files

Image

Redacted configuration

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

  1. added
    providerProvider adapters, OpenAI-compat presets, upstream API quirks
    on Sep 29, 2026
  2. lidge-jun commented on Sep 29, 2026

    @lidge-jun
    Owner

    Fixed on dev by #6249. The Qwen3.8 chat template rejects a system message after the first turn (System message must be at the beginning.) and does not accept developer, so for translated Qwen3.8-27B routes a later instruction is now sent as a user message in its original position; other destinations are unchanged. Not verified against a live AMD endpoint. Ships in the next release; please reopen with a redacted request log if the error persists.

  3. K9ineX3D commented on Oct 1, 2026

    @K9ineX3D
    Author

    This issue still persist for the model Qwen3.8-Flash-Next no matter the provider or harness. You can check it via any provider.
    Btw 3.8 27B works
    Raw logs has been provided below.

    Image Image
    {
      "requestId": "ocx-f588fccd24993ea85e2df4cf99722700",
      "timestamp": 1790840465696,
      "model": "Qwen3.8-Flash-Next",
      "provider": "AMD",
      "surface": "claude",
      "admissionKind": "loopback",
      "inboundProtocol": "messages",
      "accountLogLabel": "kb697860e8b4c1dd0df9938d2160aeca1",
      "conversationId": "11d36ad5d7886b58c5856814aa80018b",
      "requestedModel": "AMD/Qwen3.8-Flash-Next",
      "requestedAlias": "AMD/Qwen3.8-Flash-Next",
      "requestedEffort": "xhigh",
      "effectiveEffort": "xhigh",
      "reasoningWireField": "reasoning_effort",
      "reasoningWireValue": "xhigh",
      "configuredServiceTier": "fast",
      "configuredSpeedLabel": "fast",
      "modelSupportsServiceTier": false,
      "tierOutcome": {
        "wireKind": null,
        "wireValue": null,
        "fastOutcome": "unknown",
        "confirmation": "unknown"
      },
      "resolvedModel": "Qwen3.8-Flash-Next",
      "servedModel": "Qwen3.8-Flash-Next",
      "status": 502,
      "durationMs": 1917,
      "errorCode": "upstream_server_error",
      "terminalStatus": "failed",
      "closeReason": "terminal",
      "upstreamError": "System message must be at the beginning.",
      "usageStatus": "unreported",
      "attempts": [
        {
          "ordinal": 1,
          "provider": "AMD",
          "model": "Qwen3.8-Flash-Next",
          "adapter": "openai-chat",
          "status": 502,
          "durationMs": 1904,
          "sendCount": 1,
          "recoveryKinds": [],
          "usageStatus": "unreported",
          "requestedEffort": "xhigh",
          "effectiveEffort": "xhigh",
          "reasoningWireField": "reasoning_effort",
          "reasoningWireValue": "xhigh",
          "tierOutcome": {
            "wireKind": null,
            "wireValue": null,
            "fastOutcome": "unknown",
            "confirmation": "unknown"
          },
          "accountLogLabel": "kb697860e8b4c1dd0df9938d2160aeca1",
          "deliverySummary": {
            "adapterEvents": 1,
            "relayedEvents": 3,
            "semanticBytes": 0,
            "sideEffectEvents": 0,
            "terminalEvents": 1
          },
          "errorCode": "upstream_server_error",
          "failureStage": "protocol-prelude",
          "failureCause": "upstream-fault",
          "resendPermission": "refused-ambiguous",
          "displayMetrics": {
            "tokPerSecond": {
              "kind": "unavailable",
              "reason": "usage_missing"
            },
            "decodeTokPerSecond": {
              "kind": "unavailable",
              "reason": "usage_missing"
            },
            "cost": {
              "kind": "unavailable",
              "reason": "usage_missing"
            }
          }
        }
      ],
      "spend": {
        "sends": 1,
        "settled": 1,
        "unresolved": 0
      },
      "transportPhase": "terminal_sse",
      "terminalSource": "upstream",
      "routeDecision": {
        "version": 1,
        "decisionId": "552a2bae5447",
        "createdAt": 1790840465708,
        "requestedModel": "AMD/Qwen3.8-Flash-Next",
        "routeKind": "explicit-provider",
        "requirements": [],
        "candidates": [
          {
            "provider": "AMD",
            "model": "Qwen3.8-Flash-Next",
            "eligible": true,
            "exclusions": []
          }
        ],
        "selected": {
          "candidateIndex": 0,
          "provider": "AMD",
          "model": "Qwen3.8-Flash-Next",
          "reason": "explicit-provider-namespace"
        }
      },
      "protocolTrace": {
        "v": 1,
        "inbound": "messages",
        "mode": "legacy-bridge",
        "upstream": "chat",
        "requestPath": [
          "messages",
          "responses-internal",
          "ir",
          "chat"
        ],
        "responsePath": [
          "chat",
          "ir",
          "responses-internal",
          "messages"
        ],
        "reasonCodes": [
          "not-migrated"
        ],
        "featureEffects": [
          {
            "feature": "request.tools",
            "disposition": "translated"
          },
          {
            "feature": "request.reasoning",
            "disposition": "degraded"
          },
          {
            "feature": "request.cache_control",
            "disposition": "degraded"
          }
        ],
        "attempts": [
          {
            "ordinal": 1,
            "upstream": "chat",
            "mode": "legacy-bridge",
            "requestPath": [
              "messages",
              "responses-internal",
              "ir",
              "chat"
            ]
          }
        ],
        "contractVersion": "2026-09-25.2"
      },
      "failureStage": "protocol-prelude",
      "failureCause": "upstream-fault",
      "resendPermission": "refused-ambiguous",
      "displayMetrics": {
        "tokPerSecond": {
          "kind": "unavailable",
          "reason": "usage_missing"
        },
        "decodeTokPerSecond": {
          "kind": "unavailable",
          "reason": "usage_missing"
        },
        "cost": {
          "kind": "unavailable",
          "reason": "combo_attempt_unavailable"
        }
      }
    }
  4. github-actions commented on Oct 1, 2026

    @github-actions
    Contributor

    Automated translation bookkeeping — detected language: English.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingproviderProvider adapters, OpenAI-compat presets, upstream API quirks

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions