Skip to content

Bug: LM Studio provider sends incompatible response_format JSON Schema (HTTP 400) #3

Description

@MachineFm

LM Studio provider always sends response_format, causing HTTP 400 JSON Schema parser error

Environment

  • OpenClaw: 2026.7.1-2 (0790d9f)
  • OS: Windows 10 Pro 22H2 (19045.6937)
  • Node.js: v24.18.0
  • Provider: Native LM Studio provider
  • LM Studio: 0.4.20
  • API Endpoint: http://127.0.0.1:1234/v1

Model:

  • lmstudio-community/Qwen3.5-4B-GGUF/Qwen3.5-4B-Q4_K_M.gguf

Description

OpenClaw sends a response_format JSON Schema to LM Studio for chat completions.

LM Studio rejects the request with HTTP 400 before inference begins.

The problem disappears immediately if response_format is not sent.


Steps to reproduce

Start LM Studio server:

lms server start --port 1234

Configure OpenClaw:

openclaw onboard \
  --non-interactive \
  --accept-risk \
  --auth-choice lmstudio \
  --custom-base-url http://127.0.0.1:1234/v1 \
  --lmstudio-api-key lmstudio \
  --custom-model-id qwen3.5-4b

Send any prompt.


Actual result

LM Studio returns:

HTTP 400

Unable to generate parser for this template.
Automatic parser generation failed:

JSON schema conversion failed:
Pattern must start with '^' and end with '$'

LM Studio log:

Engine protocol predict request returned 400:

{
  "error": {
    "code": 400,
    "message": "Unable to generate parser for this template. Automatic parser generation failed: JSON schema conversion failed: Pattern must start with '^' and end with '$'",
    "type": "invalid_request_error"
  }
}

Investigation

The request contains response_format.

Inside OpenClaw:

dist/openai-transport-stream-*.js

contains:

if (options?.responseFormat !== void 0)
    params.response_format = options.responseFormat;

Commenting out this line fixes the problem immediately.

After restarting the gateway:

  • Chat works normally
  • Tool calling still works
  • LM Studio no longer returns HTTP 400

Expected behavior

The LM Studio provider should either:

  • detect that the provider cannot consume the generated JSON Schema and omit response_format, or
  • gracefully fall back to plain text, or
  • only send response_format when the target provider explicitly supports the generated schema.

Additional information

LM Studio also prints:

Reasoning setting 'medium' is not supported.
Supported settings: 'on', 'off'.

This warning is unrelated.

The request only fails because of the transmitted response_format JSON Schema.


Suggested fix

The LM Studio provider should avoid attaching response_format by default, or perform capability detection before sending structured outputs.

A provider-specific compatibility flag similar to other provider capability checks would prevent this issue.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions