Repository navigation
fix(sandbox): move the model gateway to Bifrost v2.2.4 - #3961
Conversation
The gateway now creates its first admin account only for a request that carries the setup token it started with. The platform sends its admin password as that token in the bootstrap body, and on every management call in the header a gateway that closes its whole management plane until an admin exists reads. It also stops sending three fields the gateway ignores (enforce_governance_header, disable_auth_on_inference, allow_all_keys) and states the wire facts as verified against Bifrost v2.2.4.
Bifrost 1.6 kept serving, and billing, an abandoned whole answer to its end, and a prefill a stream was waiting on, so every resent request queued behind its own ghost on a model that serves one request at a time. v2.2 cancels the vendor call within half a second of the caller hanging up. v2.2 creates its first admin account only for a caller presenting its setup token. The gateway image derives BIFROST_SETUP_TOKEN from SANDBOX_LLM_GATEWAY_ADMIN_PASSWORD, which every Tale deployment already passes it, so no new secret exists; the dockerized dev overlay now gives the gateway its dev default, and the container smoke test checks the running gateway holds the token. The store migrates in place on first start. The upgrade guide says how to copy the gateway volume first, since an older gateway on a migrated store serves Tale but logs errors, and what changes for operators.
The gateway now cancels the vendor call when a caller hangs up, so a whole answer the caller abandoned no longer generates, and bills, to its end while its settlement waits out the request timeout. It is booked like a stream that ended early: at least its prompt and the output that reached the caller, at the catalog price, settled a few seconds after it ends. Only a request the watchdog closes as stale still waits out a whole answer's lifetime, since its process may hold its connection open. The debt entry keeps what the gateway still does not do: book the usage a cancelled call had reached.
An answer that ended early is booked at its prompt floor because the vendor may have read the prompt. A call whose connection to the gateway was never made (refused while a deploy replaces the gateway, a name that does not resolve, a connect timeout) left this process, so it books only the gateway's own figure. The old deferred read booked such a whole answer at 0; streams had booked the floor.
|
Holding this PR at
Fresh affected local suites: 161 passed. Four independent probes: 2 healthy controls passed, 2 finding expectations failed. Exact-head hosted Build/Checks/E2E attempt 1 passed; affected unit tasks show actual cache misses and gateway smoke executed 29/29. Those successes do not cover the two counterexamples. No production probing, Docker execution, or product changes were made during this independent review. Please also link the raw fixture/results for the PR's live provider/isolation and SQLite migration/backup/restore matrix, with source/image identity, so a reviewer can distinguish verified artifacts from prose claims. The current matrix remains author-reported. Upstream comparison: https://github.com/maximhq/bifrost/blob/ed8371a9779bfbc8aa689d4d77964cf8ce9308bf/transports/bifrost-http/handlers/config.go#L932 . Root retains the final independent review and normal merge gate. |
A caller that hung up while its request was still being governed (the input guardrails judging it, its budget hold being taken, its gateway key being minted) reached the relay with an aborted signal. Node's fetch then failed at once without sending a byte, yet the relay reported the call as an answer that ended early, and the settlement booked its whole prompt at the catalog price: 30 cents for a 1M-token prompt at 30 cents per million, against a gateway that received nothing. The relay now checks the caller right before it makes the gateway call and books a floor only for a call that may have left the process. A request the caller left first is closed as cancelled with nothing of its own to book, so only the gateway's figure for its unused key counts. Every hang-up after the call was made keeps its accounting: a whole answer at least its prompt, a stream its prompt and the output relayed. The endpoint docs say that a call broken off during its checks is neither sent nor booked.
The gateway image kept a BIFROST_SETUP_TOKEN set on the container, while the platform always presents the admin password as the setup token. A fresh gateway given any other token refused the platform's bootstrap with 403, so it never got its admin account, and Bifrost 2.2 leaves the management API of an unclaimed gateway open to anyone who can reach it. The token is now the admin password, always. The entrypoint replaces an explicit BIFROST_SETUP_TOKEN, says so in the log without printing either value, and reads the password the way the platform does. One secret claims the gateway and manages it, so nothing has to stay in step between two containers. A gateway that already has its admin ignores the token either way. A new platform suite runs the real entrypoint and hands its token to a management plane that decides as Bifrost 2.2.4 does, bootstrapped by the platform's own client. The container smoke test now gives the gateway a different explicit token and checks that the running process holds the password.
The upgrade guide said the first release after 0.5.63 moves the model gateway from Bifrost 1.6 to 2.2. That release is 0.5.64, which still pins Bifrost 1.6.11 and does not carry the move. The section now keys on the move itself, in English, German and French: a release after 0.5.64 makes it, and its release notes list it. The rollback paragraph names a release before the move rather than an older one.
|
All three findings from the review of 1. A call cancelled before dispatch charged its prompt (
2. An explicit setup token broke the first bootstrap (
3. Upgrade boundary ( Raw evidence for the live matrix: I could not find any raw rig, fixture or result for the author's provider/isolation and SQLite migration/backup/restore matrix. I looked in the PR body and comments, the PR's files, the CI artifacts of Local gates on
CI on
|
Why
The pinned gateway (Bifrost v1.6.11) never noticed a caller leaving a whole answer. It served, and billed, an abandoned request to its end, and the same went for a prefill that a stream was still waiting on. On a model that serves one request at a time, every resent request queued behind its own ghost (vatplus run r0014). Bifrost v2.2 cancels the vendor call as soon as the caller hangs up.
What changes
services/sandbox-llm-gateway): pinned tomaximhq/bifrost:v2.2.4.docker-entrypoint.shalways setsBIFROST_SETUP_TOKENtoSANDBOX_LLM_GATEWAY_ADMIN_PASSWORD, which is the token the platform presents, then runs the upstream entrypoint unchanged. An explicitBIFROST_SETUP_TOKENon the container is replaced, and a log notice names it without printing either value.tale deployviaenv_file: .env, compose.yml, and the documented KubernetesenvFrom: tale-env), so there is no new secret and no manifest change.compose.dev.ymlgives the gateway its dev default.BIFROST_SETUP_TOKEN, and checks that the running process holds the password.llm_gateway_admin.ts):PUT /api/configcarriesauth_config.setup_token, which is the admin password.X-Bifrost-Setup-Token. Upstream's open fix(auth): require the setup token on the management API until an admin exists maximhq/bifrost#7595 moves the management API to requiring that header until an admin exists; a gateway that already has an admin ignores it.enforce_governance_header,disable_auth_on_inferenceandallow_all_keys. Enforcement was re-checked live on both versions without them.model_api): a whole answer the caller abandoned is now cancelled at the vendor. It is booked like a cut stream, at least its prompt plus the relayed output at the catalog price, and settled a few seconds after it ends instead of after the 10+ minute request timeout. Only a request the watchdog closes as stale still waits, because a hung process may keep its connection open. A call the caller leaves before it is sent (while the guardrails judge it, or its hold or key is being made) is not sent and books nothing of its own.BIFROST_SETUP_TOKEN.llm-gateway-data, and rollback. It is keyed to the Bifrost 1.6 → 2.2 move, which comes in a release after 0.5.64 whose notes list it; no release number is guessed..agents/repo.mdnarrows the debt entry to what is still missing (usage of a cancelled call). There is a new manual box,GOV-F47, and the automation row is updated.Verified live
Test rig: an isolated gateway container and a scriptable mock upstream. The platform's own
llm_gateway_admin.tsdrove every call.This table is the author's report. Its rig, fixtures and raw results are not attached to this PR; see Review corrections below for what was independently re-run.
reasoning_contentreplayed, turn completescurrent_usagekept across a cap changeno such column: oauth_configs.token_idThe documented backup and restore commands were run against a real store volume.
Review corrections (after 2af85d2)
These answer the review of
2af85d28c(three P2 findings). Commits2d3249aec,37b2ae8caand610bc9e4dwere pushed as a fast-forward on top of it.dispatched && !neverConnected).relay.test.ts(real fetch),metering.test.ts, andv1-model-api.test.ts(hang-up during the guardrails and during the key mint). Four of them fail against the unfixed relay.BIFROST_SETUP_TOKENkept a fresh gateway from its admin.gateway_setup_token.test.tsruns the real entrypoint and gives its token to a management plane that decides as upstreamtransports/v2.2.4(ed8371a) does. The platform's ownapplyGatewayConfigthen bootstraps it. Cases: password only; distinct explicit token; explicit token equal to the password; the pre-rename name; no password (403, fail closed); installed admin with any token or none. Four cases fail against the old entrypoint.maximhq/bifrost:v2.2.4linux/amd64 binary (indexsha256:5f8215163cea…, layers sha256-verified), run as the image's entrypoint chain on loopback without Docker:GET /api/configanswered 200.config.jsonpoints the pricing datasheets at local files, because this sandbox resolves no public DNS.ebf4546) still pins Bifrost 1.6.11. The EN/DE/FR section is now keyed to the Bifrost 1.6 → 2.2 move ("a release after 0.5.64", whose notes list it).What this does not prove:
Known, not changed here
finish_reason, so an upstream that sends them before its usage frame is billed 0. The mock reproduced this. It is recorded in the debt entry; I have no evidence that a real upstream does this.message_start.count_tokenson custom records still answers 400.