Skip to content

[Provider compatibility] Aside/Prime export omits supportsDeveloperRole:false, so Aside → alibaba-token-plan-intl/qwen4-max 400s on native Chat passthrough #8864

Closed

Description

@lidge-jun

Client or integration

Aside (managed aside integration, ~/.aside/u/<id>/models.json). Prime is affected by the same code path (see notes).

Provider or upstream service

alibaba-token-plan-intl registry preset, base URL overridden to DashScope international compatible-mode (https://dashscope-intl.aliyuncs.com/compatible-mode/v1), adapter openai-chat. Model qwen4-max (GA 2026-11-16, added as a custom model).

The same gap applies to alibaba-token-plan (CN) and any other openai-chat preset that has no foldDeveloperRoleToSystem record.

OpenCodex version

2.100.4 (macOS, /Applications/OpenCodex.app). Code references below are against origin/dev @ c36793a93.

Endpoint or capability

/v1/chat/completions, native Chat→Chat passthrough (same-wire-native), developer role handling. Also the Aside client export (buildAsideContribution).

Current behaviour

Every Aside turn on alibaba-token-plan-intl/qwen4-max fails with 400 before any output. Even a single "hi" fails, and Aside's retry fails the same way.

The request log rows (~/.opencodex/usage.jsonl) for the two attempts, ocx-4297c1ef5a062a0fa1feff3cc8f4611e (16:34:41 KST) and ocx-5fc9c987ca6f268ab361906d5a5c5c91 (16:34:52 KST):

{
  "provider": "alibaba-token-plan-intl",
  "model": "qwen4-max",
  "inboundProtocol": "chat",
  "requestedEffort": "high",
  "status": 400,
  "attempts": [{ "adapter": "openai-chat", "status": 400, "errorCode": "invalid_request_error",
                 "failureStage": "headers-only", "failureCause": "payload-rejected" }],
  "upstreamCondition": "request_rejected",
  "failureDetail": { "code": "provider_error", "type": "invalid_request_error" },
  "protocolTrace": {
    "inbound": "chat", "mode": "native", "upstream": "chat",
    "reasonCodes": ["same-wire-native"],
    "featureEffects": [
      { "feature": "request.tools", "disposition": "passthrough" },
      { "feature": "request.reasoning", "disposition": "passthrough" }
    ]
  },
  "requestBody": { "wireBytes": 262725 }
}

The root cause is two gaps that line up:

1. The Aside export does not tell Aside to send system.

buildAsideContribution (and buildPrimeContribution) call buildPiClientConfig(ctx) with no options:

// src/clients/config-export.ts
function buildPrimeContribution(ctx: ExportContext): ManagedContribution {
  const doc = buildPiClientConfig(ctx);              // no PI_EXPORT_OPTIONS
  ...
}
function buildAsideContribution(ctx: ExportContext): ManagedContribution {
  const doc = buildPiClientConfig(ctx);              // no PI_EXPORT_OPTIONS
  return singleFragment("aside", ["providers", OPENCODE_PROVIDER_ID], doc.providers[OPENCODE_PROVIDER_ID]);
}

The client table entries do the same (aside: { build: buildPiClientConfig, ... }, prime: { build: buildPiClientConfig, ... }).

Pi, omo and gentle-shell were fixed in #5664 / #5674 by passing PI_EXPORT_OPTIONS = { sendSessionAffinityHeaders: true, foldDeveloperRole: true }, which writes compat.supportsDeveloperRole: false. Aside and Prime reuse the same Pi builder and the same models.json contract, and the comment above buildAsideContribution says so, but they never received that option. The written Aside block therefore has no compat at all:

"opencodex": {
  "baseUrl": "http://127.0.0.1:10100/v1",
  "api": "openai-completions",
  "apiKey": "opencodex-loopback",
  "models": [
    { "id": "alibaba-token-plan-intl/qwen4-max", "reasoning": true, "thinkingLevelMap": { ... },
      "contextWindow": 1000000, "maxTokens": 32000 }
  ]
}

Aside's daemon is Pi-based. Its compat detection treats an unknown host like 127.0.0.1 as standard OpenAI, so supportsDeveloperRole defaults to true, and the Chat message builder picks:

role = model.reasoning && compat.supportsDeveloperRole ? "developer" : "system"

So for every reasoning: true row, Aside sends its whole system prompt as role: "developer".

2. The native Chat passthrough forwards developer verbatim for unrecorded providers.

applyExplicitChatDeveloperRole only rewrites the role when foldDeveloperRoleToSystem is explicitly recorded (explicitChatDeveloperWireRole returns undefined for the absent state). moonshot and mistral record true (#7583 / #7584). Neither Alibaba preset records anything, although #5664 already documented DashScope rejecting the role:

developer is not one of ['system','assistant','user','tool','function']

The local config has foldDeveloperRoleToSystem: undefined for alibaba-token-plan-intl, so the developer message goes upstream unchanged and DashScope returns 400.

The translated route would have folded it (translatedChatDeveloperWireRole defaults to system). Only the native route is exposed.

3. (Secondary) The rejection reason is hidden.

The client receives only:

{"error":{"message":"The provider rejected the request.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

The dashboard shows "Payload rejected / Request rejected". Neither the client body, the dashboard nor the usage log row carries the upstream message that names developer, so the cause can only be found by bisecting the request by hand.

Expected behaviour

  • An Aside (and Prime) export writes compat.supportsDeveloperRole: false, the same as Pi/omo/gentle-shell since fix(openai-chat): Pi developer role and duplicated serialized tool calls (lane F2) #5674, so Aside sends system and the request succeeds on every destination behind the single opencodex provider block.
  • Independently, the Alibaba presets (alibaba-token-plan, alibaba-token-plan-intl, and any DashScope compatible-mode choice) record foldDeveloperRoleToSystem: true, so a native Chat client that still sends developer is folded instead of rejected.

Minimal redacted request or reproduction

Bisected through the loopback proxy (:10100). Same provider, same model; only one field changes per probe:

Probe Result
messages:[{user:"hi"}] 200
+ reasoning_effort: "high" / "xhigh" / "max" 200
+ stream: true, stream_options.include_usage 200
+ tools (plain, strict: true, anyOf/const params, parallel_tool_calls) 200
two system messages, one mid-conversation 200
[{role:"developer",content:"a"},{role:"user",content:"hi"}] 400, same headers-only / payload-rejected / request_rejected row as the Aside failure
same, with role:"system" 200
curl -s http://127.0.0.1:10100/v1/chat/completions \
  -H 'content-type: application/json' \
  -d '{"model":"alibaba-token-plan-intl/qwen4-max","max_tokens":5,
       "messages":[{"role":"developer","content":"a"},{"role":"user","content":"hi"}]}'
# {"error":{"message":"The provider rejected the request.","type":"invalid_request_error",...}}

curl -s http://127.0.0.1:10100/v1/chat/completions \
  -H 'content-type: application/json' \
  -d '{"model":"alibaba-token-plan-intl/qwen4-max","max_tokens":5,
       "messages":[{"role":"system","content":"a"},{"role":"user","content":"hi"}]}'
# 200, chat.completion

Aside side, end to end: open a new Aside chat on opencodex / alibaba-token-plan-intl/qwen4-max and send "hi". It returns 400 immediately and the retry fails too.

Workaround that confirms the mechanism: hand-adding "compat": {"supportsDeveloperRole": false} to the qwen4-max row in ~/.aside/u/1/models.json makes Aside send system. It is not persistent, because the next managed refresh rewrites the owned providers.opencodex fragment (same clobbering problem #5664 described for Pi).

Actual response or error

To the client:

{"error":{"message":"The provider rejected the request.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

Dashboard: 400 Payload rejected, failure cause Payload rejected (reached: headers only), upstream reason Request rejected, Not resent: the same request would fail again, duration ~400 ms, usage not reported.

Upstream body (per #5664, same gateway family): developer is not one of ['system','assistant','user','tool','function'].

Upstream documentation

Alibaba Cloud Model Studio OpenAI-compatible mode has no public page listing the accepted roles. The accepted set is stated by the upstream 400 itself (['system','assistant','user','tool','function'], see #5664).

Aside's behaviour comes from its bundled Pi runtime: compat is detected per host, and supportsDeveloperRole falls back to true for an unrecognised host. Aside's own built-in Chat model definitions (Kimi Coding, Copilot-hosted models, its first-party gateway) set supportsDeveloperRole: false explicitly. The opencodex block is the one that leaves it to detection.

Suggested mapping or implementation notes

  1. Export fix (primary, covers every destination at once). Pass PI_EXPORT_OPTIONS (or at least { foldDeveloperRole: true }) in buildAsideContribution, buildPrimeContribution, and the build: of the aside / prime client table entries, so ocx export --client aside and the managed contribution cannot drift. Check whether sendSessionAffinityHeaders is also correct for Aside before copying the whole options object. Aside's compat parser accepts it, but it was not part of this failure.
  2. Registry fix (defence in depth). Record foldDeveloperRoleToSystem: true on alibaba-token-plan and alibaba-token-plan-intl, following the moonshot/mistral precedent and the derive.ts / routed-config.ts backfill so existing configs pick it up without re-adding the provider. This also covers non-Pi Chat clients that send developer.
  3. Diagnostics (nice to have). On payload-rejected, keep a redacted excerpt of the upstream error message (or at least param) in the usage row and the dashboard detail. "The provider rejected the request." with no upstream text turned a one-line cause into a manual bisect.

Additional context and attachments

Checks

  • I searched existing provider and compatibility issues.
  • The request and response were redacted.
  • The expected behaviour is based on an upstream specification or a concrete client requirement.

Activity

  1. added
    bug
    provider-compatibility
    provider
    on Nov 17, 2026
  2. coderabbitai commented on Nov 17, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #8278 - fix(mistral): sanitize Chat fields and normalize native thinking content [closed]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

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

    bugproviderprovider-compatibility

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions