Which version of LM Studio?
LM Studio 0.4.20+1
Claude Code version 2.1.216
Which operating system?
macOS 26.6
What is the bug?
When running claude --model openai/gpt-oss-120b I get the following error
500 Engine protocol predict request returned 400: {"error":{"code":400,"message":"Failed to initialize samplers: failed to parse grammar","type":"invalid_request_error"}}
Logs
From lms log stream --source runtime
runtime.log
From lms log stream --source server
Streaming logs from LM Studio
[2026-07-29 13:41:23][INFO][openai/gpt-oss-120b] Running Anthropic messages API on conversation with 3 messages.
[2026-07-29 13:41:23][INFO][openai/gpt-oss-120b] Streaming Anthropic response...
[2026-07-29 13:41:23][ERROR][openai/gpt-oss-120b] Anthropic streaming error: Engine protocol predict request returned 400: {"error":{"code":400,"message":"Failed to initialize samplers: failed to parse grammar","type":"invalid_request_error"}}
[2026-07-29 13:41:23][INFO][openai/gpt-oss-120b] Finished streaming Anthropic response
[2026-07-29 13:41:23][INFO][openai/gpt-oss-120b] Running Anthropic messages API on conversation with 3 messages.
[2026-07-29 13:41:23][ERROR][Server Error] {
"type": "error",
"error": {
"type": "api_error",
"message": "Engine protocol predict request returned 400: {\"error\":{\"code\":400,\"message\":\"Failed to initialize samplers: failed to parse grammar\",\"type\":\"invalid_request_error\"}}"
}
}
[2026-07-29 13:41:24][INFO][openai/gpt-oss-120b] Running Anthropic messages API on conversation with 3 messages.
[2026-07-29 13:41:24][ERROR][Server Error] {
"type": "error",
"error": {
"type": "api_error",
"message": "Engine protocol predict request returned 400: {\"error\":{\"code\":400,\"message\":\"Failed to initialize samplers: failed to parse grammar\",\"type\":\"invalid_request_error\"}}"
}
}
[2026-07-29 13:41:25][INFO][openai/gpt-oss-120b] Running Anthropic messages API on conversation with 3 messages.
[2026-07-29 13:41:25][ERROR][Server Error] {
"type": "error",
"error": {
"type": "api_error",
"message": "Engine protocol predict request returned 400: {\"error\":{\"code\":400,\"message\":\"Failed to initialize samplers: failed to parse grammar\",\"type\":\"invalid_request_error\"}}"
}
}
To Reproduce
Steps to reproduce the behavior:
- Download openai/gpt-oss-120b
lms server start
export ANTHROPIC_BASE_URL=http://localhost:1234 export ANTHROPIC_AUTH_TOKEN=lmstudio export CLAUDE_CODE_ATTRIBUTION_HEADER=0
claude --model openai/gpt-oss-120b
- Type
hello, see error
From ChatGPT:
My conclusion
I think this is almost certainly an LM Studio bug (or an incompatibility in the bundled llama.cpp version) affecting Claude Code + gpt-oss.
The runtime is rejecting the generated GBNF before inference starts:
parse: error parsing grammar:
number of repetitions exceeds sane defaults
That's a parser limitation, not a model limitation.
After running the following cURL command ChatGPT had me try which succeeded
curl http://localhost:1234/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: lmstudio" \
-d '{
"model":"openai/gpt-oss-120b",
"max_tokens":32,
"messages":[
{
"role":"user",
"content":[
{
"type":"text",
"text":"Say hello."
}
]
}
]
}'
it came back with the following
That means:
The model is fine.
The Anthropic Messages API is fine.
The Claude Code connection is fine.
The grammar Claude Code generates for tool use is what triggers the bug when LM Studio adapts it for gpt-oss.
Notice in the runtime log that the grammar contains definitions for Claude Code's tools (tool-Bash, tool-Agent, tool-DesignSync, etc.), not just a simple JSON grammar.
The plain curl request never asks for tool calling, so LM Studio never has to generate that enormous grammar—which is why it succeeds.
Which version of LM Studio?
LM Studio 0.4.20+1
Claude Code version 2.1.216
Which operating system?
macOS 26.6
What is the bug?
When running
claude --model openai/gpt-oss-120bI get the following errorLogs
From
lms log stream --source runtimeruntime.log
From
lms log stream --source serverTo Reproduce
Steps to reproduce the behavior:
lms server startexport ANTHROPIC_BASE_URL=http://localhost:1234 export ANTHROPIC_AUTH_TOKEN=lmstudio export CLAUDE_CODE_ATTRIBUTION_HEADER=0claude --model openai/gpt-oss-120bhello, see errorFrom ChatGPT:
After running the following cURL command ChatGPT had me try which succeeded
it came back with the following