Skip to content

General gateway fixes from the Atlas integration branch - #38

Merged
data-angel merged 8 commits into
mainfrom
fix/atlas-general-fixes
Sep 27, 2026
Merged

data-angel merged 8 commits into
mainfrom
fix/atlas-general-fixes

Conversation

@data-angel

Copy link
Copy Markdown
Contributor

Summary

Five commits from atlas/installable-20260924 that aren't Atlas-specific, split out so they land now. The Atlas recipe, backend and image pins stay on that branch.

  • Model acquisition: keep checkpoint paths and invalidate stale receipts when acquisition fails.
  • Multimodal forwarding: Responses input_image / input_video parts keep their detail and descriptor fields. Video payloads get the same opaque-media token estimate as images, so base64 video is no longer counted as prompt text. The Atlas recipe and docs parts of the original commit were dropped.
  • Runtime policy: lloom runtime-policy sets explicit memory limits through validated CLI writes.
  • Tokenize: /tokenize proxies exact token counts to the serving backend.
  • Structured output: a JSON Schema that can't be compiled is refused up front.

Test plan

  • npm run test:unit (full chain, pass)
  • node --test test/runtime-policy-config.test.mjs test/tokenize-route.test.mjs
  • eslint + prettier on the changed files. bin/lloom.mjs is already unformatted on main and was left as is.

🤖 Generated with Claude Code

data-angel and others added 8 commits September 27, 2026 11:57
Responses input_image/input_video parts keep their detail and descriptor
fields, and video payloads get the same opaque-media token estimate as
images. Split from the Atlas integration branch (1e8d984) without its
Atlas-specific recipe and docs.
The Atlas engine renders a chat template whose exact token count decides
whether a long-context request fits, but the gateway had no way to ask for
it: `/v1/tokenize` was not routed, so an exact-count client could only
estimate. Add the route as a thin pass-through.

The body is forwarded untouched apart from the upstream model name,
including `chat_template_kwargs`, because rewriting it would change the
count the endpoint exists to report. `prompt` and `messages` are both
accepted, matching the backend's own contract. Missing input and unknown
models are rejected as client errors before any upstream call so a bad
request cannot occupy a backend slot.

Atlas serves its OpenAI surface under `/v1` but token counting at the bare
`/tokenize`, and an OpenAI-typed backend's baseUrl already ends in `/v1`.
Joining the route to that base would request `/v1/tokenize` and the engine
answers 404, so the handler resolves the backend origin explicitly and
`upstreamUrl` now passes an already-absolute URL through instead of
prepending the baseUrl to it.

Tests cover the forwarded route and absolute resolution for baseUrls with
and without `/v1`, upstream-model substitution, template kwargs
preservation, input validation, and verbatim propagation of a backend
rejection.

Verified: node --check, prettier --check, tokenize route tests, security,
model failover, server resilience, smoke, and a live request through the
gateway to the Atlas engine.
A caller-supplied `response_format.json_schema.schema` was forwarded to the
backend untouched. When it carried `type: "invalid"` the backend ignored the
constraint it could not compile and answered 200 with ordinary text, so a
client that asked for schema-constrained output silently got an
unconstrained response and no error.

Reject the request instead, before any backend call, via
`assertCompilableSchema`. The check is deliberately conservative: only a
`type` that is not one of the seven JSON Schema types is refused, at the root
or at any place the specification puts a subschema (properties, items,
combinators, definitions, `$defs`, `dependentSchemas`, and the conditional
keywords). `$ref`, `enum`, `const`, `format` and unknown keywords pass
through, and the failing path is named in the error.

The same check now guards `lloom.outputSchema`, which reaches the same
construction by a different route.

Verified: node test/protocol.test.mjs, protocol-stream, security,
responses-codex, model-failover and tokenize-route suites, plus
prettier --check.
@data-angel
data-angel merged commit 46411e9 into main Sep 27, 2026
2 checks passed
@data-angel
data-angel deleted the fix/atlas-general-fixes branch September 27, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant