Skip to content

System message must be at the beginning - LiteLLM/vLLM/Qwen3 #311

Description

@JKratto

Short description

vLLM/Qwen3 throws "System message must be at the beginning" error - plugin prepends context before system message (similar to cortexkit/aft#150)

What happened?

When using magic-context with OpenCode, I'm encountering a BadRequestError from vLLM when using Qwen3.6 27B model:

litellm.BadRequestError: Hosted_vllmException - {"error":{"message":"System message must be at the beginning.","type":"BadRequestError","param":null,"code":400}}

This error persists even with model fallbacks (Qwen3.6-27B → Qwen3.5-9B). The issue appears to be that magic-context is prepending context messages before the system message in the message list, which violates vLLM's/chat tempplate's requirement that the system message must be the first message.

Related Issue: This appears similar to cortexkit/aft#150, which also involved system message positioning.

Environment:

  • OpenCode with magic-context plugin
  • Model: Qwen3.6-27B served by vLLM through LiteLLM

Diagnostics

Plugin version

v0.36.1

OpenCode version

1.18.18

Platform

macOS arm64

Client

OpenCode TUI (CLI)

Log output (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions