Repository navigation
Description
Context
Hosted search loses its configured reranker on every call. Jev is a built-in reranker (jevReranker, packages/core/src/providers/rerankers/jev.ts:227; registered at packages/core/src/lib/registry.ts:73). It calls https://api.typesafe.ai (jev.ts:32) with TYPESAFE_API_KEY (jev.ts:33). Governed and strict workers never get that key, and the CLI provider relay cannot carry it:
- The relay only knows three request families:
ProviderRelayFamily = "gemini" | "anthropic" | "openai"(packages/common/src/provider-relay.ts:31), each with fixed routes (ROUTES,packages/ui-sdk/src/server/provider-relay.ts:82). ListingTYPESAFE_API_KEYinBRAIN_UI_CLI_PROVIDER_ORIGINSdoes not help, because Jev's request shape matches none of them. - The worker CLI therefore prints
jev reranking unavailable: the host withholds TYPESAFE_API_KEY from agent workers(providerUnavailableNotice,packages/common/src/provider-unavailable.ts:64-72). It falls back tolifecycle_order, and the host records aprovider_unavailablegovernance event. - The 0.44.0 release notes call this out as an accepted gap ("video and Jev remain unavailable inside these workers"). Video has since been relayed (core: relay the Gemini Files video lifecycle for brain video watch in keyless workers #2738). Jev has no tracking issue.
Observed on a hosted 0.44.0 install (2026-11-04 to 2026-11-09). 26 provider_unavailable events, all provider: jev, capability: reranking, degradedTo: lifecycle_order. They came from brain_search on both backends, in 11 of the 19 sessions active in that window. On an install that enables Jev, every hosted search therefore runs without it.
Scope
- Add Jev as a relayed provider: a
typesaferelay family (name decided in the PR) whose only route is the reranking endpoint Jev calls. The first-party origin ishttps://api.typesafe.ai, and the key is placed by the host, as for the existing families (FIRST_PARTY_PROVIDER_RECIPIENTS,packages/ui-sdk/src/server/provider-relay.ts:68-72). - Make the in-worker Jev client go through the relay when
BRAIN_PROVIDER_RELAY_SOCKETis set, as the other relayed providers do. Keep the notice only for hosts without the relay. - Meter relayed Jev calls in the turn budget like the other relayed providers. If Jev pricing is not known, record them as
unknownRuns, not$0.
Out of scope
- The sync judge's Jev use in maintenance workers, and the model alias mismatch (core: the sync judge requests the moving
jev-latestalias while the reranker pinsjev-1.13.0, through two Jev transports and twoJEV_MODELconstants #2504). - Choosing or evaluating rerankers (Epic: choose the decision model per use case — Jev, Clef or Clef-flash — on evals that can tell them apart #918).
- Giving workers the key.
Acceptance criteria
- A governed worker's
brain searchwithrerank: jevconfigured is reranked through the relay. A keyless test proves it, with a loopback stand-in on the Jev route, and asserts that the stand-in received the host-placed key and the worker never held it. - A request from the worker to any other path or origin under the new family is refused by the relay, with a test.
- No
provider_unavailablenotice or event is produced when the relay is available. Hosts without the relay keep the current notice. - Relayed Jev calls appear in the turn's budget accounting, and an unknown cost never reads as
$0.
Verification
bun run test packages/ui-sdk/tests(provider-relay cases) andpackages/corereranker tests.- Mutation: route the in-worker client directly instead of through the relay, and the key-placement test fails.
Contract impact
Additive CONTRACT. docs/integration-contract/cli.md ("Provider relay", including its family/request table and x-brain-provider header) already makes the relay family and native request route a compatibility surface. Extend it in the same CONTRACT: commit, update the host environment/relay references and affected API reports, and supply a minor changeset. The shared implementation exports remain internal; the request/configuration contract does not. Preserve exact-origin/key binding, existing request validation, cancellation, budget admission and provider-history stability.
Triage 2026-11-09 at main 9c7eb25825fdad5f4485db0df472188805edb450: Verified the actual Jev endpoint (POST /v1/systemone), host key placement and the documented relay family contract. Resolved conditional contract wording from source; no provider call or pricing claim was made. The complete credential-free worker/host-relay deliverable directly advances #1645, rather than #918’s model-selection evaluation.
Activity
schlessera commentedon Nov 15, 2026
Claimed for implementation. Claim token:
claim-95914f30. Branch:feat/3792-relay-jev-reranking.Path collision: #4008 (docs/integration-contract/cli.md). Closure-only overlaps with several open PRs.
CONTRACT: feat(ui-sdk,core): relay Jev reranking for governed workers (…
schlessera commentedon Nov 15, 2026
Delivered in #4024, squash
86003b261fd6ae94397bf8c522032f2f8eb7fd5aon main (milestone 0.45.0).typesafefamily whose only route isPOST /v1/systemone. The host places itsTYPESAFE_API_KEYas a bearer token forhttps://api.typesafe.ai, or an exact origin the operator lists. Any other method, path, query, origin or key under the family is refused before contact.jevreranker goes through the relay. Itsbrain searchandbrain_searchare reranked, with noprovider_unavailablenotice. A host without the relay keeps the notice.reranking. It is unpriced, so it counts as unknown spend and toward the unpriced-token stops, never as$0.TYPESAFE_API_KEY, as before, because their sync judge and propagation review call TypeSafe directly. That use is out of scope here.docs/integration-contract/cli.mdand the index, with a minor changeset.Proof (details in the PR):