mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #18] [MERGED] serve: treat unset/-1 max_tokens as remaining context, not 1024 #2418
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2418
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/18
Author: @coolio986
Created: 9/27/2026
Status: ✅ Merged
Merged: 9/27/2026
Merged by: @Niko1221
Base:
main← Head:fix/unlimited-max-tokens📝 Commits (1)
a40fe52serve: treat unset/-1 max_tokens as remaining context, not 1024📊 Changes
2 files changed (+147 additions, -11 deletions)
View changed files
📝
serve/server.py(+17 -11)➕
serve/test_server.py(+130 -0)📄 Description
Clients that send
max_tokens: -1(unlimited),0,null, or omit it were capped at 1024 tokens — the oldor 1024fallback, plus the<= 0 -> 1024clamp added in #7. Replies stopped at 1024.Changes
Service.prepare(..., max_new=None)resolves the budget after tokenizing and returns(ids, thinking, max_new). Unset/non-positive budget = remaining context.CTX_SLACK = 8:strata --serverejectsprompt + max_new + 8 > context(src/program/generate.cpp), so Python now uses the same margin. Unlimited =max_context - 8 - len(ids); explicit budgets are checked against the same room (400 up front instead of an engineERRmid-stream).max_tokens/max_completion_tokensstill honored exactly;_debug_reqlogs the resolved budget.Tests
New
serve/test_server.py(unittest, MockEngine behind a real HTTP server): -1/0/missing/null on both APIs, explicit budgets,max_completion_tokensprecedence, explicit overflow -> 400, near-full prompt.python -m unittest serve.test_server-> 5 tests OK. Reverting to the 1024 fallback fails 14–16 checks.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.