Skip to content

Support DashScope (Alibaba Cloud Bailian) provider with role mapping (developer → system) #19130

@Putzhuawa

Description

@Putzhuawa

title: "Support DashScope (Alibaba Cloud Bailian) provider with role mapping (developer → system)"
labels: ["enhancement", "provider-support", "dashscope"]

🐛 Problem Description

Alibaba Cloud Bailian (DashScope) API's OpenAI-compatible endpoint does not support the developer role, which OpenClaw uses by default for system prompts. This causes all DashScope models (including Qwen3.5-Plus) to fail with HTTP 400 errors.

Error Message

HTTP 400: developer is not one of ['system', 'assistant', 'user', 'tool', 'function'] - 'messages.['0'].role'

🔍 Root Cause

DashScope's OpenAI-compatible API (https://dashscope.aliyuncs.com/compatible-mode/v1) only accepts these roles:

  • system
  • user
  • assistant
  • tool
  • function

But does NOT support:

  • developer (OpenClaw default)

📋 Steps to Reproduce

  1. Configure DashScope provider in ~/.openclaw/openclaw.json:
{
  "models": {
    "providers": {
      "dashscope": {
        "baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
        "apiKey": "sk-xxxxxxxx",
        "api": "openai-completions",
        "models": [
          {
            "id": "qwen3.5-plus-2026-02-15",
            "name": "Qwen3.5-Plus",
            "reasoning": false,
            "contextWindow": 1000000,
            "maxTokens": 65536
          }
        ]
      }
    }
  }
}
  1. Set primary model to DashScope:
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "dashscope/qwen3.5-plus-2026-02-15"
      }
    }
  }
}
  1. Restart OpenClaw Gateway:
openclaw gateway restart
  1. Send any message to the agent

  2. Expected: Model responds normally

  3. Actual: HTTP 400 error with role validation failure


✅ Verification Tests

Test 1: Using system role (works)

curl -X POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.5-plus-2026-02-15",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello"}
    ]
  }'

Result: ✅ Success (200 OK, valid response)

Test 2: Using developer role (fails)

curl -X POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.5-plus-2026-02-15",
    "messages": [
      {"role": "developer", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello"}
    ]
  }'

Result: ❌ HTTP 400 Bad Request


💡 Proposed Solution

Add provider-level role mapping configuration to OpenClaw:

Option 1: Provider-level configuration

{
  "models": {
    "providers": {
      "dashscope": {
        "baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
        "api": "openai-completions",
        "roleMapping": {
          "developer": "system"
        }
      }
    }
  }
}

Option 2: Built-in DashScope provider detection

Automatically detect DashScope provider and map developersystem:

  • Check if baseUrl matches dashscope.aliyuncs.com
  • Apply role mapping automatically

📚 Additional Context

DashScope Endpoints

  • China Mainland: https://dashscope.aliyuncs.com/compatible-mode/v1
  • Singapore: https://dashscope-intl.aliyuncs.com/compatible-mode/v1
  • US (Virginia): https://dashscope-us.aliyuncs.com/compatible-mode/v1

Important Configuration Notes

  1. reasoning must be false for DashScope models in OpenClaw config
  2. Model IDs vary between SDK and HTTP API:
    • SDK: qwen3.5-plus
    • HTTP API: qwen3.5-plus-2026-02-15

Reference Documentation


🔗 Related Issues

Similar role mapping solutions have been implemented for other providers:

  • Minimax: Switched from OpenAI to Anthropic endpoint to avoid role conflicts
  • This suggests OpenClaw already has infrastructure for provider-specific role handling

🎯 Impact

This issue prevents users from using Alibaba Cloud Bailian's Qwen models (including the powerful Qwen3.5-Plus with 1M context window) with OpenClaw, limiting options for users in China or those seeking cost-effective alternatives to Western AI providers.


Environment

  • OpenClaw Version: 2026.2.15
  • OS: Windows 11
  • Node: v24.13.0
  • DashScope API: OpenAI-compatible mode
  • Model Tested: qwen3.5-plus-2026-02-15

Thank you for considering this enhancement! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions