Skip to content

[Auto] session_failure: The request was malformed and could not be processed. litellm.BadRequestError: O #765

Closed

Description

@igorcosta

Auto-Reported Autohand CLI Error

Field Value
Error Type session_failure
CLI Version 0.9.8
Model default
Provider custom:spark-loader
Platform darwin 27.0.0
Session ID 47b56a05-f623-45ba-8cc3-a90676b0435a-1794984000863
Report ID ZsyrOeSrar8zVuOTy7Xyc

Error Message

The request was malformed and could not be processed.
litellm.BadRequestError: OpenAIException - System message must be at the beginning.. Received Model Group=qwen3.8-flash-next-tp1
Available Model Group Fallbacks=None

Stack Trace

ApiError: The request was malformed and could not be processed.
litellm.BadRequestError: OpenAIException - System message must be at the beginning.. Received Model Group=qwen3.8-flash-next-tp1
Available Model Group Fallbacks=None
    at buildFriendlyError (/$bunfs/root/autohand-macos-arm64:87190:26)
    at async makeRequest (/$bunfs/root/autohand-macos-arm64:87109:42)
    at async complete (/$bunfs/root/autohand-macos-arm64:87042:48)
    at processTicksAndRejections (native:7:39)

Session Context

  • Conversation length: 3 messages
  • Context usage: 46%
  • Last tools used: N/A
  • Retry attempt: 0 / 3

Additional Context

{
  "clientType": "cli",
  "retryAttempt": 0,
  "maxRetries": 3
}

Auto-reported by Autohand CLI v0.9.8 | Report ID: ZsyrOeSrar8zVuOTy7Xyc

Activity

  1. added
    bug
    on Nov 18, 2026
  2. igorcosta commented on Nov 19, 2026

    @igorcosta
    ContributorAuthor

    Reported from CLI 0.9.8. The request failed because the CLI sent system notes in the middle of the conversation, which this OpenAI-compatible endpoint rejects ("System message must be at the beginning").

    This was fixed in 0.9.10: custom providers go through normalizePromptRoles (src/providers/messagePayload.ts), which merges leading system messages into one and sends later system notes as user context. Upgrading to 0.9.10 or later resolves it.

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

    auto-reportedbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions