A body the engine's count routes could not take (native /generate
fields, /v1/responses' input) was judged by the 2.5 bytes a token
average, so a body of digits, one token each, went past the limit
uncounted, into the zone the engine queues and never admits. The native
/generate shape is now counted (ids count themselves, text is a prompt)
and what still cannot be counted is judged by the one byte a token bound
where a wedge is possible; elsewhere the average decides as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The oversize guard charged a video a flat 4,096 tokens, where SGLang's
own video sizing (768 frames, VIDEO_TOTAL_PIXELS) lets one cost about
88,000, and a body of a dozen video URLs is a few kilobytes that the
byte estimate never nominated for a count. Where a wedge is possible,
each video part now adds its ceiling to the nomination and to the count,
so such a body is counted and refused as too long; lanes whose engine
refuses past its own window keep the flat budget and see no change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Kolibri lane runs vLLM 0.29.0, and four things the proxy assumed of SGLang are not true
there, each measured against the real engine on 2026-10-14:
- no /server_info: the pool is the kv_cache_size_tokens label of /metrics' cache_config_info
and the window /v1/models' max_model_len (without them every body past 256 KiB was held
as "not measured yet" for good);
- a model it does not serve is a 404: a body naming another model gets the served one, so a
client set up for one lane keeps working on this one (SGLang bodies are never touched);
- a closed connection stops the request (no /abort_request): closing replaces draining;
- the vocabulary probe needs the served name and reads vLLM's wording (128,000 tokens).
What was learned of one engine (vocabulary, x-override-rid) is dropped when another names
itself; System One says it needs a Qwen lane. PROXY_HOLD_UNITS names the Kolibri unit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MemoryMax=1G with MemorySwapMax=0: the highest peak over two weeks of real traffic was
101 MB. On a box with swap, MemoryMax alone moves the excess to swap (measured: a unit
capped at 100M held 300M); with both, the kernel stops the proxy alone and systemd
starts it again 3 s later.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without the identity wall, the engine's key is the port's one gate (README), and a
request without it still had its body read whole and, when large, counted by the
engine on the proxy's own key before the engine's 401. The proxy now applies the
engine's own rule first (measured on the live engine: bearer in any case, one space,
the key exactly) and answers the engine's own 401, before the body and before an
Expect: 100-continue invitation; /health and /metrics stay open. The test harnesses
decide which key their proxy holds, whatever HOME holds: those that give it one
present it, as every real client does, and those whose clients send none give it
none (the CI's offline step gives HOME a key). The cockpit knows the new outcome.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Where the engine accepts a prompt past the share of its pool this guard lets through
(the 27B lane: 863,638 accepted, 794,552 usable, measured 2026-10-08), a body is
nominated by its bound, one byte a token, not by the 2.5 average that let digit-heavy
text through uncounted; nothing under 200 kB was looked at, whatever the pool. Where
the engine's window is under that share (the flash lane), it refuses past it itself and
the average nominates as before: counting there was measured at +115 ms for a lone
300 kB prompt and +1.65 s for eight at once. A body the engine cannot count is judged
as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a batch that mixes a request asking for token_ids_logprob with one that does not,
the served 27B build (v0.5.19) fills a bare list for the one that did not ask and
calls .tolist() on every entry: its scheduler dies (sglang#34719, open). Refused at the
top of a /generate body and in the parameters of /vertex_generate, the only places the
engine reads it; a value the engine treats as absent passes, the OpenAI routes are not
touched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The review's sub-agent reports were each verified by hand against the
installed SGLang before anything was changed; what they got wrong was
dropped.
keepalive-proxy:
- the guards judged the raw JSON value, but the engine's pydantic models
coerce 999999, "999999" and 999999.0 to the same int before the
scheduler runs, so a crash shape typed as a string sailed through the
ceiling and the token-id refusals (_engine_int, checked against the
installed build field by field);
- /vertex_generate also judged parameters.sampling_params, which the
scheduler spreads into its SamplingParams (stop_token_ids and n were
reachable there; top_logprobs_num is not, and the guard does not
over-refuse it).
- the version moves to v6.27 and says what the second pass found.
dashboard:
- num_inference_steps is bounded server-side on the video lane (1 to 100,
as the image lane already does) instead of trusting the page's slider;
- the stop message no longer promises a 5 s cut the unit never makes (it
waits up to 60 min); the curl preview no longer prints a task the
server refuses;
- the video lock hand-off now carries the timeout with the call that
timed out instead of re-reading a global a test could already have
restored; the vacuous download assertion in the async test is now a
real one.
installers:
- install-image.sh starts the lane that was serving again after its smoke
test even when that lane was the video or the llamacpp one;
- install-video.sh refuses a VIDEO_BIND=0.0.0.0 that would put a keyless
generator on every interface.
Every change is held by a test that failed before and passes after; the
full offline suite (proxy, dashboard, installers) and ruff F,E9 are
green.
S4: a key spelled with a JSON \u escape ("\u0074op_logprobs") carried
none of the bytes the guards scanned for, so the ceiling and the token-id
refusals were skipped; any escape in the body now forces the parse.
S5: the sampling and logprob guards also cover /v1/responses, /invocations
and /vertex_generate, read input_ids as a batch of lists, read
sampling_params as a list, read prompt as token ids on /v1/completions,
and the oversize guard reaches /generate and the other non-/v1/
generation routes.
S6: the TLS handshake no longer runs in the accept loop (one silent
connection parked every other client behind its timeout); it now runs in
the connection's own thread on its own budget, and a handshake that dies
leaves one journal line, no traceback.
Each change is held by a test that failed before and passes after; the
full offline suite and ci-local are green.
- ruff F,E9 ran over a hand-kept list that left out engine-inputs.py and oc-merge-limits.py,
both run by install.sh: the list comes from the tracked .py files now (the vendored
flash-sglang/ overlay excepted), with a floor. An undefined name in either passed before.
- The isolation test ran one file and compared HOME alone, while four files left UPSTREAM,
KEEPALIVE_S, CLIENT_IO_S, MAX_SILENCE_S, PROMPT_CEILING_TOKENS or SGLANG_API_KEY set for
every module after them. Every unittest file now runs in a process of its own (four at
a time, about 20 s here) and must hand back the whole environment, and the four restore
what they set when their class is done. A class that moved HOME, or set UPSTREAM, and
never put it back passed before.
- TheRender in test_lean_level.py needs jinja2, which no step installed: it ran only
because the runner's python ships it, and without it the lean step reported OK with
the render skipped. The discovery step installs it, and the TypeSafe SDK.
- 17 steps only re-ran a unittest module the discovery step already runs (combined, then
each file directly) and the offline step runs again: four runs of each, no assertion
added. They are gone, with the two installs they carried moved into the discovery step
(one of them had a name YAML cut at its " #").
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- "a smaller pool is picked up after invalidation" wrote the new pool into the cache by
hand after invalidating: it reads through pool_tokens() from a fake /server_info now,
so an invalidation that drops nothing fails it (it passed on its own before).
- "a deep schema is left untouched and reported" never read the report: the depth-bound
line must be logged.
- "a non-streamed wall of markers is named" asserted only that the answer arrives: the
proxy's journal line naming the corruption is read too.
Each mutant (a no-op invalidation, a silent depth bound, a silent corruption check) passed
its test before and fails it now.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A missing ~/.config/qwen38/api-key used to be written as "test-key" and deleted at
tearDownClass, which a Ctrl-C skips; install.sh keeps a key it finds. The in-process
proxies are handed the key, the proxies run as processes get a HOME of their own, and
test_suite_isolation sets the five fixtures up in an empty HOME and fails if anything
appears there (it fails on the old fixtures).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- P3: an Anthropic body goes to the engine's own /v1/messages/count_tokens
(its conversion, tools included), each image priced from its header and
replaced by an empty text block (an empty list is a 500 there). Measured on
the box: five screenshots in tool_result blocks were counted 2,044,251 and
refused, the engine serves 28,463 (28,458 counted now); 8 tools, 422 counted
before, 2,709 now and served
- P4: a raw control or non-ASCII byte in the query is a 400, not a dropped
socket and a "client vanished" line
- P5: the logged-once memories keep 16-byte digests, 512 at most; the moved
effort is printed 40 characters long (five 20 MB values: 22 -> 346 MiB and
a 20,000,137-character journal line each, before)
- P7: a client named by the identity wall is named on the request's first
line too, as one word; the cockpit's feed accepts the label after the peer
- P6: the cockpit greps the banner in its current shape ("on 0.0.0.0:30001");
it showed v6.20 while v6.24 ran. U7: the too-old-to-abort warning compares
versions part by part, server-side (as floats, v6.2 to v6.9 passed)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The cockpit asks /v1/loads?include=core (projected to the /get_load shape)
and /server_info; the keepalive proxy (v6.23) and oc-fit-limits.py ask
/server_info, conc-check.py /model_info. Each falls back to the deprecated
route only on a 404. Both SGLang images log a warning per call of the old
routes: 597 + 20 in ten minutes of the 27B's journal, now none.
- install.sh tags each pinned image present on the box
(qwen38-pinned:<lane>-<digest>): an untagged digest pull is dangling, and
docker image prune deleted it. uninstall.sh knows the tag, removes an image
by all its references, and warns about prune only for an untagged image.
- install-agent.sh's nested install-dashboard.sh run prints only the relay.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A TEXT BOOT THAT FLOODS ITS LOG SENT THE BAR BACK TO THE START. The lifecycle
parses the last 300 lines of the engine's log while health is down. The 27B
boot at 21:50 today logged inductor compile errors during the graph capture
(`LLVM ERROR: Unsupported rounding mode`, caught by inductor, the boot went on
to ready in 426 s; the same noise shows on three of today's eleven boots): 850
lines in all, every milestone out of the window, stage None, and the lane
went from "capturing graphs" back to "starting" for the rest of its boot.
Within one activation the stage now stays the last one the log proved, and a
new activation starts from its own log.
A cockpit that did not watch the boot (restarted in the middle of it, or
after) had nothing to carry, so the start of the boot is read once per
activation, bounded to its first 15 minutes: the container is created at
each start, so those minutes are this boot's own and hold every milestone up
to "fired up". Checked against the live container: start computed at
21:50:58, the unit's own ActiveEnterTimestamp; 850 lines; warming-up, fired
up, both weight loads. The same read fixes a quieter error: a serving engine
that lost health, to a cockpit that had not seen it boot, read "starting"
(its tail is decode lines, stage None) and now reads "degraded". Nothing acts
on that difference (the wedge belt only runs from "ready"); it is what the
page says.
THE PROXY SENT TEXT CLIENTS TO WAIT FOR AN ENGINE THAT WAS NOT COMING
(v6.22). With the box switched to images, the text engine is stopped on
purpose and does not come back by itself, and the proxy answered "stopped,
restarting or still loading (a restart takes minutes, about 9)". The error
path, and only it, now asks systemd whether qwen38-image.service is active,
at most every 5 s, and names the image lane and the way back. Tested against
the real proxy process with a stand-in systemctl in both directions, and
with the real one on the box (inactive: the answer it always gave). Proxy
v6.22 deployed and serving: a real chat completion through :30001 in 0.7 s.
CHANGELOG: a v1.18.0 entry for the image lane, marked unreleased; the date
and the tag belong to the release.
Five collector tests (the flood, a new activation, evidence over memory, the
read-once, degraded not starting) and two proxy tests; the carry-over, the
head read and the proxy message were each undone once and their tests failed.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Both listened on every interface, and this box shows what that was worth.
Seven days of journal: 581,479 requests to the engine and 8,288 to the proxy,
every single one from 127.0.0.1, while the machine was reached from a laptop
and a phone on the cockpit port alone. Two ports open to a LAN and a tailnet,
used by nobody but the box itself, and they are the two SGLang dies on rather
than refuses (sglang#40076, sglang#31597, refused at the proxy since v1.15.0).
The proxy's guards protect what goes through the proxy; a port that bypasses
it is a door beside the one with the lock.
ENGINE_BIND and PROXY_BIND close them. The defaults do not move: somebody
else's laptop may legitimately point at either port, and a default must never
take away something the operator did not ask to lose. An installed choice wins
over the default in both directions, which is the part that matters, because a
box hardened to localhost that a plain ./install.sh reopened would be the worst
of the three outcomes: nobody would have a reason to look. A bad value is
refused by name before a unit is written, not by a unit that fails to start
minutes later on a box whose engine has just been stopped.
The proxy is v6.21 for it. The version gate added in v1.15.2 earned its place
on the first try: the bind changed the shape of the startup line, the banner
stopped matching the history block, and the test failed before this could ship.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
v1.15.1 fixed the history block and left the startup banner and the module
docstring saying v6.19, so a deployed box printed v6.19 in its journal while
its cockpit read v6.20 from the same file. One fact, three copies, no gate.
The test asserts the three agree and that the history stays newest-first,
because the cockpit reports the first entry it finds. Checked by reverting the
banner and watching it fail, not by reading it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two of them passed here and failed on CI. The probe reads the serving key
before it sends anything, and a runner has no key file: _api_key() raised
inside served_vocab(), the probe never left, and the tests that assert it
probes saw zero calls. They passed locally only because a developer's box
keeps that file.
The key is stubbed now, so they assert the guard. And the case CI exposed is
worth a test of its own rather than a fix: with no readable key the vocabulary
stays unknown, which stands the two id checks down and refuses nothing it
cannot judge, while a negative id is still refused because no vocabulary can
hold one.
Verified the way CI runs it, with the key file moved aside: all six proxy
suites green.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reading logprobs is what /v1/systemone does, so an audit went looking at what
else can ask for them. OpenAI documents top_logprobs as "an integer between 0
and 20"; SGLang declares it Optional[int] with no constraint and hands it to
logprobs.topk(max_k), where a number past the vocabulary raises "selected index
k out of range" INSIDE the scheduler. One request from one client ends the
engine for everybody, and this box needs about nine minutes to come back
(sglang#40076, open). It was then reproduced the hard way here, by relaying one
such request during a test of the refusal meant to prevent it.
sglang#31597 catalogued the same family in July with reproductions, and both
PRs that bounded them were closed without being merged, which is why the first
had to be reported again in September. Checked one by one in the served
v0.5.19: stop_token_ids indexes a scatter_add_ out of bounds whenever
min_new_tokens > 0; input_ids indexes the embedding, and the validator that
would stop it has zero callers; n becomes parallel_sample_num unbounded. All
reachable from an ordinary chat request.
So the proxy refuses them, on the three relayed routes that carry the logprob
count under three names, element by element when a batch sends a list. The two
id fields need the vocabulary, which the engine publishes nowhere, so it is
asked for the only way it is offered: an out-of-range logit_bias is refused
with a message that names it. One probe an hour, built to be refused, never
reaching the scheduler; it matched the checkpoint's config.json to the digit.
A negative id is refused whatever happens, and a probe that fails stands the
rest of the guard down rather than refuse traffic it cannot judge.
Three defects of this route's own, found in the same audit and in review:
* the retry that asks a second, wider time went straight to the engine
without the door, and ignored SYSTEMONE_TOP_K_MAX, the clamp an operator
sets because their build refuses a wide top-k
* a percent-encoded non-ASCII byte in any path decoded to something
http.client encodes as ASCII, raising UnicodeEncodeError, a ValueError no
arm here catches: an empty reply and a traceback, before any key is checked
* a lone surrogate outside the state cost a full fan-out and returned 500;
the check now runs over the whole parsed request, before any inference, and
never echoes the text it cannot encode
* a branch still queued for a slot was aborted with a rid the engine had
never seen, then sent anyway when a slot freed
And one trap written down rather than fixed, because the code was already right
and nothing said why: on the speculative path this lane runs, the engine
divides the logprobs it returns by the request's temperature, and on the
ordinary path it does not. Only the 1.0 this route sends makes the two agree.
keepalive-proxy.py at 84% branch coverage, floor raised to 83.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The flash lane serves 262,144 tokens and opencode was allowed 175,000 of them.
The ceiling that capped it was not wrong, it was stale: it came from the v1.5
engine, whose PLE mapping faulted in whole page-cache folios and made a long
prefill cost ~0.27 GiB per 1k tokens past 90k. v1.8 serves an engine that trims
that, and nobody re-measured.
Measured now, MemAvailable sampled through every prefill, engine up 19 h with
the PLE budget filled: 195,784 tokens cost 1.16 GiB and 94.7 s; 225,051 cost
1.57 GiB and 111.3 s; 249,500 cost 1.52 GiB and 126.1 s with the floor at 6.9
GiB. Needle 3/3 exact at 200,058 / 230,231 / 249,838. Flat past 200k, an order
of magnitude under the v1.5 engine. Memory is no longer what caps this lane;
max_req_input_len (262,138) is.
- The one-prompt ceiling is 250,000, leaving 12,138 tokens under the engine's
wall. The flash context tier becomes 225,000 / 32,000. Compaction fires at
205,000 instead of 155,000 and the chain still closes on the measured worst
step: 225,000 - 20,000 + 43,863 = 248,863 <= 250,000. Verified live: a
248,796-token prompt served through the proxy in 136 s, one above the ceiling
still refused with code context_length_exceeded.
- --allow-auto-truncate is gone from the launcher and gated out of every lane.
It was undocumented. A probe asked for a prompt above the window and got back
prompt_tokens exactly equal to max_req_input_len with a confident answer, the
needle gone, and no warning: the engine had quietly cut the context. The proxy
already refuses above the ceiling, so the flag bought nothing and cost the one
failure worse than a refusal. Takes effect on the next engine start.
- Compaction stops throwing the window away. opencode's preserve_recent_tokens
default is min(15000, max(2000, threshold/4)), and that cap was chosen for
128K models: here a compaction at 205,000 would keep 15,000 and summarise
190,000. The installed value is a quarter of the threshold (51,000), sized by
oc-limits.sh --preserve and rewritten by every install and switch, with prune
on so stale tool output is cleared instead of the conversation summarised.
- A switch now reaches the server that reads the numbers. opencode serve parses
opencode.json once at startup and never again: with 225,000 on disk the
running server still answered 175,000 on /config, so every switch left the
Agent tab compacting against the previous lane's window. install.sh and
switch-model.sh restart opencode-web.service after the last config write.
- An image the guard cannot parse is charged its geometric ceiling (16,386), not
the flat budget: a 3840x2160 screenshot really costs 8,162, so the flat 4,096
under-counted it, which is the direction that lets an oversize prompt through.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The flash lane died mid-session with a proxy 400 whose number was wrong. On
2026-09-12 a conversation was refused as 200,684 prompt tokens against the
lane's 200,000 ceiling; the engine was serving 139,868.
The gap was 24 screenshots. /tokenize returns an image's 3-token placeholder,
not its expansion, so since v6.8 the oversize guard charged every media part a
flat 4,096 tokens. Measured against this engine at twelve sizes, an agent
screenshot costs 880 (1280x720) to 1,562 (1680x950). All eight oversize
refusals this box has logged were sessions holding images.
The guard now prices an image from its own header (PNG, JPEG, GIF, WebP) with
the vision tower's geometry: round(w/32) * round(h/32) cells clamped into the
processor's pixel range, plus two wrapper tokens. Exact against the engine at
all twelve sizes including both clamp branches, and end to end at 1, 5 and 24
images. Every checkpoint this repo serves has the same geometry, so one formula
covers both lanes; TOKENS_PER_MEDIA stays as the fallback for what has no
readable header. Replayed live: the refused conversation now serves at 139,548.
The refusal also became recoverable. opencode answers a context overflow by
compacting and dropping media attachments, which is the right move here, but
only when it recognises the error: a fixed message vocabulary, or error.code ==
"context_length_exceeded". The old message matched nothing and carried no code,
so the session resent the same prompt and got the same 400 (23:18:00 at
200,684, 23:18:03 at 200,735, no compaction between). error.type stays
context_too_long, because needle.sh reads it.
The 175,000 context tier keeps its number and loses its reason. opencode does
not estimate its context: it compacts when the last response's reported usage
reaches limit.input - min(20,000, output cap), from the engine's own numbers.
What it cannot see is the step it is about to take, so the rule is threshold
plus one worst step under the ceiling. Measured over 2,156 flash-lane steps in
opencode's session store: worst step 43,863, p99 18,512. 175,000 gives 198,863
under a 200,000 ceiling; 190,000 gave 213,863. oc-fit-limits derives its margin
from those measurements, and a CI gate holds the invariant and the agreement
between tool and table.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude Code 2.1.266 could not open a session on this lane: every request came
back 400 "Tool 1 function has invalid 'parameters' schema ... is not a 'regex'".
SGLang validates each tool's parameters with Draft202012Validator.check_schema
(serving_chat.py:868), whose 'regex' format check compiles 'pattern' with
Python's re. JSON Schema says 'pattern' is ECMA-262, which has Unicode property
escapes; re answers "bad escape \p". One tool carrying such a pattern (Claude
Code's Artifact, on its 'field' argument) refuses the whole session.
The proxy (v6.13) removes only the patterns Python cannot compile, only inside
tool parameter schemas (input_schema and function.parameters, request level and
message level). A body carrying none of the JSON-escaped markers \\p{, \\P{, (?<
is forwarded untouched and unparsed, so the hot path pays one substring scan; a
prompt quoting such a regex is never rewritten; the walk is depth-bounded; each
distinct dropped pattern is logged once.
Reproduced against the live lane (400), answered 200 with the same body after
the fix. tests/test_proxy_guard.py grew five cases and runs 30.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
SGLang sizes the pool from MemAvailable at the instant it profiles (psutil on an
integrated GPU, confirmed in the image), so two boots of the identical launcher
drew 189,056 and 249,408 tokens today, and the bigger draw cost 6 GiB of the
host headroom a 120k prompt spends. The launcher pins --max-total-tokens 190000
(served as 189,952 after page alignment), the envelope every needle and canary
result in this repo was measured in, and waits up to 180 s for MemAvailable to
clear 96 GiB before starting; measured, a stopping lane's memory is back within
one second of the container exit, so the wait costs nothing on a normal switch.
Verified on the reference box after the change: pool 189,952, idle 23.7 GiB,
needle 2/2 at 120k with a 14.9 GiB floor, canaries 4/4, and _qsa_split_kernel
(KDA) is the only QSA kernel compiled in the container: the Triton fallback was
never called.
The cockpit recorded one boot in five because it read the engine_info cache at
the ready transition, which then holds the boot's connection errors or the
previous engine's facts; it reads the engine directly now, and says when a pool
comes up short of its pin. The recipe parser drops full-line comments, since a
comment naming a flag was parsed as the flag. Proxy v6.12 trips at 128 marker
characters and ends the OpenAI stream with [DONE]. The v1.6 and v1.6.1 release
notes were republished whole.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
When the decode path loses its state on this hardware it does not stop, it
emits runs of token id 0, which is "!" in the Qwen tokenizer. The client reads
that as the answer. It is the visible face of sglang#36537 / #36558 / #36806 /
#36845 and the reason the flash lane is still beta.
The proxy now counts marker characters across the stream and, past
CORRUPTION_RUN of them in a row (48 by default, 0 disables), aborts the
generation upstream and sends the client an explicit corrupted_output error in
its own dialect. It reads only the delta text it already relays, never
tool-call arguments, so prose with "!!!" in it is untouched; a non-streamed
answer cannot be withheld once it is on the wire, so there the guard names it
in the log instead.
Nine unit tests on the run counter and the dialect readers, plus an end-to-end
test whose fake engine streams 4,000 exclamation marks: the stream is cut, the
client gets corrupted_output, and /abort_request is called with the right rid.
Verified live on the reference box: v6.11 serving, a normal answer containing
"bravo!!!" relayed untouched.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UXuj8DiygLTBQPxfVSWrgM
pool_tokens() cached the KV pool for 600 seconds and never dropped it. Nothing
invalidated the cache on an engine restart, so for up to ten minutes the
oversize guard enforced the limit of an engine that was gone.
That matters because the pool is not a constant. It is a boot lottery for one
checkpoint (863,398, 893,479 and 913,334 measured here) and it changes outright
between lanes: about 863k on the 27B lane against 184k on flash. A prompt
accepted against a stale larger pool and relayed to a smaller engine is exactly
the case v1.5.4 added this guard for, where the scheduler busy-loops forever
with /health still answering.
The cache is now dropped whenever the engine proves unreachable (both 503 paths)
and whenever a refresh read fails, since a failed read is itself evidence the
engine moved. Three tests cover it, and the one that matters goes red when the
invalidation is removed: I checked by putting the bug back.
Tests: tests/test_proxy_guard.py 15 ok (12 before), ./ci-local.sh 20 ok.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BxM8C7oTYmxJsXAqHfV6nb
Field case 2026-08-30 01:15: the flash engine restarted after a GPU fault (Xid 31,
illegal memory access in the QSA indexer prefill) and the oversize guard, unable to
reach /tokenize, refused a 68,626-token request as 'at least ~408841 tokens by size'.
Now every path answers 503 with Retry-After and a message that says the request was
not refused for its size; upstream 5xx (SGLang while starting) gets the same message.
Tests: connection refused, 5xx, 4xx, and the real proxy in front of a fake loading engine.
The KV pool is not the limit on the flash lane: the prefill of a long prompt grows
the engine's footprint by ~0.27 GiB per 1k tokens beyond ~90k on a 128 GB box
(measured 29/08 at fraction 0.81: 120k +7.4 GiB, 135k +11.4, 150k +15.3 with
the first driver allocation refusals, 177k +22.8 with MemAvailable at 0.8 GiB and
15 NVRM out-of-memory kernel lines). The proxy now caps one prompt at a token
count set per lane by install.sh through the keepalive unit (flash 135000, the
largest clean point; 27B unset), on top of the pool share. CI renders the new
placeholder; 9 proxy tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The v6.7 guard divided the body size by 2.5 chars per token and refused
everything above the KV pool. English prose runs 3.4 to 4.6 chars per token,
so a 140k-token prompt (479 KB) was refused as 192k tokens although the pool
served it (measured in the 29/08 soak: 60k, 100k, 120k looped fine, 140k got
400 every time). Now the size only nominates a body; the engine's /tokenize
(present in both images this repo ships, 644 ms for 474k chars) gives the exact
prompt length, chat template applied, Anthropic bodies converted, media parts
counted as a fixed 4096-token budget instead of their base64 text. Refusal
above 92 percent of the pool (OVERSIZE_MARGIN_FRAC, the README's 165K of
178,560); size-based refusal stays as the fallback when the engine cannot count.
8 offline tests with a fake /tokenize, wired into CI.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>