LM Studio HTTP 500 hides a context-size error

Verified October 17, 2026. Firsthand Kingy test evidence.

LM Studio 0.4.26+4; llama.cpp Metal engine 2.60.0. Existing artifact SHA-256: 7485fe6f11af29433bc51cab58009521f205840f5b4ae3a32fa7f92e8534fdf5.

Failure and correction

The native LM Studio API wrapped a typed inner context-size rejection in an outer HTTP 500. The retained request contained 518 rendered input tokens while the loaded model had a 512-token context.

{
  "error": {
    "message": "Engine protocol predict request returned 400: {\"error\":{\"code\":400,\"message\":\"request (518 tokens) exceeds the available context size (512 tokens), try increasing it\",\"type\":\"exceed_context_size_error\",\"n_prompt_tokens\":518,\"n_ctx\":512}}",
    "type": "internal_error",
    "code": "unknown",
    "param": null
  }
}

Reload the same model instance with a larger supported context. The retained correction used lms load qwen3-4b --context-length 2048 --gpu max --parallel 1 --identifier kingy-memory-lms. The load setting must take effect before repeating POST /api/v1/chat.

Acceptance

Preserve the full original input and enough output room, then verify every required fact. Here, 2048 was a tested setting for one 518-token synthetic request, not a universal minimum or a memory-fit promise.

{
  "start_code": "ALPHA-17",
  "middle_code": "BRAVO-42",
  "end_code": "CHARLIE-93"
}
AttemptHTTPTask acceptedSeconds
baseline 1500False2.46
baseline 2500False0.08
baseline 3500False0.12
shared corrected 1200True2.41
shared corrected 2200True0.9
shared corrected 3200True0.86
reverted500False2.48

Limits and retained failures

Same agent, one Apple M4 Pro Mac with 24 GiB unified RAM, one Qwen3-4B Q4_K_M artifact. No independent human or second-machine reproduction.

Three baseline failures, three corrected exact-task passes and one reverted failure per repair. The two repairs for each runtime share the identical three corrected attempts; these are six unique corrected generations total, not twelve.

Fixed synthetic task, not a reliability estimate or proof for other models, versions or hardware. No real OOM condition was induced. No Ollama or LM Studio memory-fit calibration is claimed.

Existing weights were reused, with no model download or paid inference. A free official Ollama portable runtime was added; runtime binaries and weights are excluded from the evidence ZIP.

The earlier CPU-only cohort is unqualified: two corrected passes followed by a 120-second timeout. It remains in the evidence. The qualified cohort kept Metal GPU offload fixed across its conditions.

Native /api/v1/chat exposes no finish_reason. Acceptance required strict exact JSON, all original facts, zero reported reasoning tokens and reported output below the 128-token cap; no observed stop marker is claimed.

Evidence and references

Download requests, raw responses, protocol and audit. Runtime binaries, private logs, model weights and user data are excluded.

API reference: LM Studio native chat, LM Studio CLI. These references describe the API; the attempt files establish the observed results.

Open the browser-local debugger