[GH-ISSUE #4446] [GUI] /v1 requests over 12 MiB get a 500, and the App Host's limit is hard-coded, so the engine's STRATA_MAX_BODY_MIB never applies #1986

Closed
opened 2026-11-04 01:55:47 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kiwigloballimited-hub on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4446

Area: [GUI] (the App Host gateway that serves the OpenAI-compatible API)

Desktop app, Terminal or source? Desktop app (Windows; the client is a Mac on the network)

What happened

Two things in apps/host/server/:

  1. The limit is hard-coded and lower than the engine's. index.mjs:2052 reads every
    POST /v1/chat/completions, /v1/messages and /v1/responses body with
    readBody(req, 12 * 1024 * 1024). The same 12 MiB appears at :1774 and :1981 for the
    /api/chat/* routes. Nothing configures it. Meanwhile serve/server.py:6495 body_limit()
    defaults to 256 MiB and honours STRATA_MAX_BODY_MIB — but that code is only reached after the
    gateway has forwarded the body, so through the app the effective limit is always the smaller
    12 MiB and the documented knob does nothing. The same applies to the 4 MiB default in
    util.mjs:27 for every other route that calls readBody(req).

  2. Going over it is reported as a 500. readBody (util.mjs:27-42) throws a plain
    new Error('Request body too large'), with no status or code, and the top-level catch in
    index.mjs:986-987 maps every thrown error to error(res, 500, err.message). So a request that
    is merely too large comes back as HTTP 500 {"error":"Request body too large"}. index.mjs:1755
    already maps e.code === 'too-big' to 413 for another route, and serve/server.py answers this
    same condition with 413 before reading the body — this path is the outlier, not the rule.

Smallest steps that reproduce it

# Two ~7 MB base64 images in one user message: over 12 MiB before the conversation history is counted.
python - <<'PY' | curl -sS -i -X POST http://<windows-box>:<port>/v1/chat/completions \
  -H 'content-type: application/json' --data-binary @-
import json
img = "data:image/jpeg;base64," + "A" * (7 * 1024 * 1024)
print(json.dumps({"model": "<loaded model>", "max_tokens": 8, "messages": [{"role": "user",
  "content": [{"type": "text", "text": "two photos"},
              {"type": "image_url", "image_url": {"url": img}},
              {"type": "image_url", "image_url": {"url": img}}]}]}))
PY

Observed: HTTP 500 with {"error":"Request body too large"}; the body is refused before it is
forwarded, so nothing about the request reaches the engine. Expected: either the request is accepted
up to the engine's limit, or it is refused with 413 and a message that names the limit.

Why it matters beyond one report

An agent client that sends a photo or two per turn (Hermes here, but any OpenAI-compatible agent)
resends the conversation every turn: a 3–5 MB JPEG is 4–7 MB once base64-encoded, so the second or
third turn crosses 12 MiB and every later request fails the same way. A 500 reads as a server fault,
so the client retries the identical oversized body or reports the model as broken, and the picture
feature appears to die mid-conversation while the engine is healthy.

Suggested fix, two parts

  1. Make the gateway limit configurable. Read STRATA_MAX_BODY_MIB (the name the engine already
    uses) at the /v1 call site and as readBody's default, falling back to the engine's 256 MiB, so
    one variable controls the whole path. Exposing it in Serving settings would be the nicer version.
  2. Answer 413. Have readBody set err.status = 413 (or err.code = 'too-big', which :1755
    already understands) and have the catch-all use err.status ?? 500. Rejecting on Content-Length
    before reading, as serve/server.py does, would also avoid buffering an oversized body into RAM
    first.

Environment

  • Strata: 0.2.7 desktop app on Windows — code inspected at tag v0.2.7
  • Client: Hermes agent on a Mac, OpenAI-compatible POST /v1/chat/completions over the network
  • Hardware: Windows PC; model loaded with Read pictures on (the request is refused before it
    reaches the engine, so the GPU and RAM do not enter into this one)

Reproduction status: reproduced locally by the reporter (Windows app, agent client on a Mac,
1–2 large images per turn); the line references above were checked against v0.2.7.

Originally created by @kiwigloballimited-hub on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4446 **Area:** [GUI] (the App Host gateway that serves the OpenAI-compatible API) **Desktop app, Terminal or source?** Desktop app (Windows; the client is a Mac on the network) **What happened** Two things in `apps/host/server/`: 1. **The limit is hard-coded and lower than the engine's.** `index.mjs:2052` reads every `POST /v1/chat/completions`, `/v1/messages` and `/v1/responses` body with `readBody(req, 12 * 1024 * 1024)`. The same 12 MiB appears at `:1774` and `:1981` for the `/api/chat/*` routes. Nothing configures it. Meanwhile `serve/server.py:6495` `body_limit()` defaults to 256 MiB and honours `STRATA_MAX_BODY_MIB` — but that code is only reached after the gateway has forwarded the body, so through the app the effective limit is always the smaller 12 MiB and the documented knob does nothing. The same applies to the 4 MiB default in `util.mjs:27` for every other route that calls `readBody(req)`. 2. **Going over it is reported as a 500.** `readBody` (`util.mjs:27-42`) throws a plain `new Error('Request body too large')`, with no status or code, and the top-level catch in `index.mjs:986-987` maps every thrown error to `error(res, 500, err.message)`. So a request that is merely too large comes back as `HTTP 500 {"error":"Request body too large"}`. `index.mjs:1755` already maps `e.code === 'too-big'` to 413 for another route, and `serve/server.py` answers this same condition with 413 before reading the body — this path is the outlier, not the rule. **Smallest steps that reproduce it** ```bash # Two ~7 MB base64 images in one user message: over 12 MiB before the conversation history is counted. python - <<'PY' | curl -sS -i -X POST http://<windows-box>:<port>/v1/chat/completions \ -H 'content-type: application/json' --data-binary @- import json img = "data:image/jpeg;base64," + "A" * (7 * 1024 * 1024) print(json.dumps({"model": "<loaded model>", "max_tokens": 8, "messages": [{"role": "user", "content": [{"type": "text", "text": "two photos"}, {"type": "image_url", "image_url": {"url": img}}, {"type": "image_url", "image_url": {"url": img}}]}]})) PY ``` Observed: `HTTP 500` with `{"error":"Request body too large"}`; the body is refused before it is forwarded, so nothing about the request reaches the engine. Expected: either the request is accepted up to the engine's limit, or it is refused with `413` and a message that names the limit. **Why it matters beyond one report** An agent client that sends a photo or two per turn (Hermes here, but any OpenAI-compatible agent) resends the conversation every turn: a 3–5 MB JPEG is 4–7 MB once base64-encoded, so the second or third turn crosses 12 MiB and every later request fails the same way. A 500 reads as a server fault, so the client retries the identical oversized body or reports the model as broken, and the picture feature appears to die mid-conversation while the engine is healthy. **Suggested fix, two parts** 1. **Make the gateway limit configurable.** Read `STRATA_MAX_BODY_MIB` (the name the engine already uses) at the `/v1` call site and as `readBody`'s default, falling back to the engine's 256 MiB, so one variable controls the whole path. Exposing it in Serving settings would be the nicer version. 2. **Answer 413.** Have `readBody` set `err.status = 413` (or `err.code = 'too-big'`, which `:1755` already understands) and have the catch-all use `err.status ?? 500`. Rejecting on `Content-Length` before reading, as `serve/server.py` does, would also avoid buffering an oversized body into RAM first. **Environment** - Strata: `0.2.7` desktop app on Windows — code inspected at tag `v0.2.7` - Client: Hermes agent on a Mac, OpenAI-compatible `POST /v1/chat/completions` over the network - Hardware: Windows PC; model loaded with **Read pictures** on (the request is refused before it reaches the engine, so the GPU and RAM do not enter into this one) **Reproduction status:** reproduced locally by the reporter (Windows app, agent client on a Mac, 1–2 large images per turn); the line references above were checked against `v0.2.7`.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6660454953 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1986
No description provided.