[GH-ISSUE #4036] [Engine] Responses rejects the documented -1 and 0 output-token limits #1743

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

Originally created by @Jackmeson1 on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4036

Area

[Engine] (speed, kernels, models, the server and API)

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

What happened

/v1/responses returns HTTP 400 for max_output_tokens: 0 and max_output_tokens: -1, with "max_output_tokens must be a positive whole number". The integer control max_output_tokens: 2 succeeds.

docs/DETAILS.md:1072-1073 says that max_tokens, max_completion_tokens, and max_output_tokens of -1 or 0 mean "no cap": the answer may use the room left in the context. In my comparison requests, chat max_tokens: 0 and -1 both allowed the 81-token answer to finish.

Expected: /v1/responses accepts the documented -1 and 0 sentinel values and applies no additional output-token cap, subject to the remaining context.

Commit 5c8dd32 restored these sentinel values in the server's common validation and documentation. It removed check_max_tokens, which named all three fields, but did not change the separate rejection of values below 1 in serve/responses.py:445-447. That check runs through serve/server.py:7319.

Smallest steps or command that reproduce it

The same build and config as in #4035 (commit 7dd5cf18). Server:

cd /content/Strata
python3 serve/server.py --engine strata --config /content/area3_config.json --host 127.0.0.1 --port 18091

Client:

import json
import urllib.error
import urllib.request

base = "http://127.0.0.1:18091"
prompt = "Count from 1 to 30, separated by single spaces, and nothing else."


def post(path, body):
    req = urllib.request.Request(
        base + path,
        data=json.dumps(body).encode(),
        headers={"Content-Type": "application/json"}
    )
    try:
        with urllib.request.urlopen(req, timeout=300) as response:
            return response.status, json.load(response)
    except urllib.error.HTTPError as e:
        return e.code, json.loads(e.read() or b"{}")


def chat(field, value):
    body = {"model": "strata", "messages": [{"role": "user", "content": prompt}],
            "temperature": 0, "reasoning_effort": "none", field: value}
    status, r = post("/v1/chat/completions", body)
    if status != 200:
        return {"status": status, "error": r.get("error", r)}
    c = r["choices"][0]
    return {"status": status, "finish_reason": c["finish_reason"],
            "completion_tokens": r["usage"]["completion_tokens"], "content": c["message"]["content"]}


def responses(value):
    body = {"model": "strata", "input": prompt, "temperature": 0, "reasoning": {"effort": "none"},
            "max_output_tokens": value}
    status, r = post("/v1/responses", body)
    if status != 200:
        return {"status": status, "error": r.get("error", r)}
    return {"status": status, "response_status": r.get("status"), "incomplete": r.get("incomplete_details"),
            "output_tokens": (r.get("usage") or {}).get("output_tokens")}


cases = [
    ("chat max_tokens", lambda v: chat("max_tokens", v), [2, 0, -1]),
    ("responses max_output_tokens", responses, [2, 0, -1]),
]
for name, fn, values in cases:
    for v in values:
        print(json.dumps({"case": name, "value": v, **fn(v)}))

These cases are a subset of a larger client I ran; the log lines below are excerpts from that run, unchanged.

Reproduction status

Reproduced locally

Strata version

Commit 7dd5cf18e6 (main), engine 0.1.49.2

Graphics card, memory and system

NVIDIA RTX PRO 6000 Blackwell Server Edition 97,887 MiB · 176 GiB RAM · Ubuntu 24.04.4 LTS (Linux 6.6.122+, Google Colab), driver 580.82.07, CUDA 13.0.88, GCC 13.3.0, Python 3.13.16, AMD EPYC 9B45 (48 logical CPUs)

Model, size and settings

Qwen3.8-Flash-Next GSQ-RCO Q2_0 · 4096 context · INT8 KV · the config in #4035

Logs

Excerpts from my run, 2026-10-25:

{"case": "chat max_tokens", "value": 2, "status": 200, "finish_reason": "length", "completion_tokens": 2, "content": "1 "}
{"case": "chat max_tokens", "value": 0, "status": 200, "finish_reason": "stop", "completion_tokens": 81, "content": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30"}
{"case": "chat max_tokens", "value": -1, "status": 200, "finish_reason": "stop", "completion_tokens": 81, "content": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30"}
{"case": "responses max_output_tokens", "value": 2, "status": 200, "response_status": "incomplete", "incomplete": {"reason": "max_output_tokens"}, "output_tokens": 2}
{"case": "responses max_output_tokens", "value": 0, "status": 400, "error": {"message": "max_output_tokens must be a positive whole number", "type": "invalid_request_error", "param": "max_output_tokens", "code": null}}
{"case": "responses max_output_tokens", "value": -1, "status": 400, "error": {"message": "max_output_tokens must be a positive whole number", "type": "invalid_request_error", "param": "max_output_tokens", "code": null}}

Not checked in this run: streaming requests, max_completion_tokens: 0/-1, or Messages max_tokens: 0/-1.

Originally created by @Jackmeson1 on GitHub (Oct 25, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4036 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Source (START-HERE.bat, setup.sh or a build) ### What happened `/v1/responses` returns HTTP 400 for `max_output_tokens: 0` and `max_output_tokens: -1`, with `"max_output_tokens must be a positive whole number"`. The integer control `max_output_tokens: 2` succeeds. `docs/DETAILS.md:1072-1073` says that `max_tokens`, `max_completion_tokens`, and `max_output_tokens` of `-1` or `0` mean "no cap": the answer may use the room left in the context. In my comparison requests, chat `max_tokens: 0` and `-1` both allowed the 81-token answer to finish. Expected: `/v1/responses` accepts the documented `-1` and `0` sentinel values and applies no additional output-token cap, subject to the remaining context. Commit `5c8dd32` restored these sentinel values in the server's common validation and documentation. It removed `check_max_tokens`, which named all three fields, but did not change the separate rejection of values below 1 in `serve/responses.py:445-447`. That check runs through `serve/server.py:7319`. ### Smallest steps or command that reproduce it The same build and config as in #4035 (commit `7dd5cf18`). Server: ```bash cd /content/Strata python3 serve/server.py --engine strata --config /content/area3_config.json --host 127.0.0.1 --port 18091 ``` Client: ```python import json import urllib.error import urllib.request base = "http://127.0.0.1:18091" prompt = "Count from 1 to 30, separated by single spaces, and nothing else." def post(path, body): req = urllib.request.Request( base + path, data=json.dumps(body).encode(), headers={"Content-Type": "application/json"} ) try: with urllib.request.urlopen(req, timeout=300) as response: return response.status, json.load(response) except urllib.error.HTTPError as e: return e.code, json.loads(e.read() or b"{}") def chat(field, value): body = {"model": "strata", "messages": [{"role": "user", "content": prompt}], "temperature": 0, "reasoning_effort": "none", field: value} status, r = post("/v1/chat/completions", body) if status != 200: return {"status": status, "error": r.get("error", r)} c = r["choices"][0] return {"status": status, "finish_reason": c["finish_reason"], "completion_tokens": r["usage"]["completion_tokens"], "content": c["message"]["content"]} def responses(value): body = {"model": "strata", "input": prompt, "temperature": 0, "reasoning": {"effort": "none"}, "max_output_tokens": value} status, r = post("/v1/responses", body) if status != 200: return {"status": status, "error": r.get("error", r)} return {"status": status, "response_status": r.get("status"), "incomplete": r.get("incomplete_details"), "output_tokens": (r.get("usage") or {}).get("output_tokens")} cases = [ ("chat max_tokens", lambda v: chat("max_tokens", v), [2, 0, -1]), ("responses max_output_tokens", responses, [2, 0, -1]), ] for name, fn, values in cases: for v in values: print(json.dumps({"case": name, "value": v, **fn(v)})) ``` These cases are a subset of a larger client I ran; the log lines below are excerpts from that run, unchanged. ### Reproduction status Reproduced locally ### Strata version Commit 7dd5cf18e68c639a8773e096c5c79f971ea2a9f5 (main), engine 0.1.49.2 ### Graphics card, memory and system NVIDIA RTX PRO 6000 Blackwell Server Edition 97,887 MiB · 176 GiB RAM · Ubuntu 24.04.4 LTS (Linux 6.6.122+, Google Colab), driver 580.82.07, CUDA 13.0.88, GCC 13.3.0, Python 3.13.16, AMD EPYC 9B45 (48 logical CPUs) ### Model, size and settings Qwen3.8-Flash-Next GSQ-RCO Q2_0 · 4096 context · INT8 KV · the config in #4035 ### Logs Excerpts from my run, 2026-10-25: ```text {"case": "chat max_tokens", "value": 2, "status": 200, "finish_reason": "length", "completion_tokens": 2, "content": "1 "} {"case": "chat max_tokens", "value": 0, "status": 200, "finish_reason": "stop", "completion_tokens": 81, "content": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30"} {"case": "chat max_tokens", "value": -1, "status": 200, "finish_reason": "stop", "completion_tokens": 81, "content": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30"} {"case": "responses max_output_tokens", "value": 2, "status": 200, "response_status": "incomplete", "incomplete": {"reason": "max_output_tokens"}, "output_tokens": 2} {"case": "responses max_output_tokens", "value": 0, "status": 400, "error": {"message": "max_output_tokens must be a positive whole number", "type": "invalid_request_error", "param": "max_output_tokens", "code": null}} {"case": "responses max_output_tokens", "value": -1, "status": 400, "error": {"message": "max_output_tokens must be a positive whole number", "type": "invalid_request_error", "param": "max_output_tokens", "code": null}} ``` Not checked in this run: streaming requests, `max_completion_tokens: 0/-1`, or Messages `max_tokens: 0/-1`.
Author
Owner

@Niko1221 commented on GitHub (Oct 27, 2026):

Thank you. Fixed in 0.2.7: /v1/responses accepts max_output_tokens of 0 and -1.

Release: https://github.com/Niko1221/Strata/releases/tag/v0.2.7

<!-- gh-comment-id:6446137385 --> @Niko1221 commented on GitHub (Oct 27, 2026): Thank you. Fixed in 0.2.7: /v1/responses accepts max_output_tokens of 0 and -1. Release: https://github.com/Niko1221/Strata/releases/tag/v0.2.7
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#1743
No description provided.