Skip to content

ui-sdk: relay Jev reranking for governed workers, so hosted search is not always unranked #3792

Closed

Description

@schlessera

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). Listing TYPESAFE_API_KEY in BRAIN_UI_CLI_PROVIDER_ORIGINS does 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 to lifecycle_order, and the host records a provider_unavailable governance 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 typesafe relay family (name decided in the PR) whose only route is the reranking endpoint Jev calls. The first-party origin is https://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_SOCKET is 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

Acceptance criteria

  • A governed worker's brain search with rerank: jev configured 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_unavailable notice 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) and packages/core reranker 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

  1. added
    type: feat
    area: core
    area: ui-sdk
    priority: p1
    on Nov 9, 2026
  2. added this to the 0.45.0 milestone on Nov 9, 2026
  3. added
    contract
    agent-ready
    on Nov 9, 2026
  4. self-assigned this
    on Nov 15, 2026
  5. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    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.

  6. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Delivered in #4024, squash 86003b261fd6ae94397bf8c522032f2f8eb7fd5a on main (milestone 0.45.0).

    • The CLI provider relay has a typesafe family whose only route is POST /v1/systemone. The host places its TYPESAFE_API_KEY as a bearer token for https://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.
    • When the key is withheld and a relay socket is present, a governed or strict turn worker's jev reranker goes through the relay. Its brain search and brain_search are reranked, with no provider_unavailable notice. A host without the relay keeps the notice.
    • Each relayed call is metered as operation reranking. It is unpriced, so it counts as unknown spend and toward the unpriced-token stops, never as $0.
    • Credentialed maintenance workers keep TYPESAFE_API_KEY, as before, because their sync judge and propagation review call TypeSafe directly. That use is out of scope here.
    • The additive contract is recorded in docs/integration-contract/cli.md and the index, with a minor changeset.

    Proof (details in the PR):

    • Failing-first and mutation receipts, including the issue's mutation: a client that bypasses the relay fails the bubblewrap key-placement cases.
    • Draft heavy feedback: all categories passed.
    • Exact-candidate confirmation passed (candidate run 43760602592). Heavy proof for the squash's own main run was still in progress at merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: corearea: ui-sdkcontractpriority: p1type: feat

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions