---
title: Jev decision provider
description: Configure the optional server-side TypeSafe provider for Team participation and visual-answer decisions.
owner: engineering
sourceFiles:
  - scripts/jev-response-eval.ts
  - scripts/jev-response-eval/model.ts
  - scripts/jev-response-eval/cases.ts
  - scripts/jev-response-eval/evaluate.ts
  - apps/server/src/runtime/jev.ts
  - apps/server/src/runtime/team-response-decision.ts
  - apps/server/src/domain/runtime/team-response-activation.ts
  - apps/server/package.json
  - packages/config/src/env.ts
  - infra/server.ts
  - .env.example
  - .env.preview
  - .env.production
---

## Configure access

Set `TYPESAFE_API_KEY` in the intended stage's secret configuration using [Proton Pass](/operations/credentials#shared-development-secrets-with-proton-pass). Use an ignored `.env.development.local` for a personal sandbox key; commit only vault references for shared environments. Alchemy supplies the key as a redacted API Worker secret. No key is required for local builds.

Hosted preview and production configurations reference the hidden `TYPESAFE_API_KEY` field on the `Environment` item in their respective `Workbench Preview Deployment` and `Workbench Production Deployment` vaults. Store a separate TypeSafe key in each vault. These keys select deployment credentials independently of the model: preview deployments also use the stable `jev-latest` default unless `JEV_MODEL` is explicitly overridden.

`JEV_MODEL` defaults to `jev-latest`. Set a versioned model identifier when reproducible model behavior is needed. See the [TypeSafe model changelog](https://docs.typesafe.ai/changelog) for available versions. The provider uses TypeSafe's direct `https://api.typesafe.ai/v1` endpoint; it does not inherit alternate SDK base URLs. See the [CLI reference](/reference/cli#jev-configuration) for configuration and plan checks.

## Use the server layer

The `@workbench/server/jev` entrypoint exports an opt-in `layer` supplying Effect's native `DecisionModel`. Importing the module performs no network requests. Building the layer requires a nonempty key and fails with a configuration error if it is absent. The Team response workflow provides this layer to its bounded participation and delivery decisions. Separately, the Team runtime builds it when its render_ui tool composes an authorized visual answer. The composer submits the current instruction and prepared candidate descriptions; raw props and state are not sent automatically. See [generated answers](/development/generative-ui) for bounds and recovery.

For another server workflow, define its input and decisions with native Effect APIs and provide the layer at that workflow's owning assembly boundary:

```ts
import * as Jev from "@workbench/server/jev";
import { Effect, Schema } from "effect";
import { Decision, DecisionModel } from "effect/ai";

const Example = Decision.make({
  input: Schema.Struct({ text: Schema.String }),
  decisions: {
    isQuestion: Decision.probability({
      instructions: "Does text ask a question?",
    }),
  },
});

const example = DecisionModel.decide(Example, {
  input: { text: "What time does the demo start?" },
}).pipe(Effect.timeout("10 seconds"), Effect.provide(Jev.layer));
```

This is an integration example, not a message-trigger policy. Run it only with a sandbox key and approved input. Application authorization must determine which content may be sent. Preserve typed `AiError` handling and avoid logging raw request/response bodies or errors that could contain submitted content. There are no automatic retries. The configured HTTP timeout covers transport until response headers; bound the entire decision, including response decoding, at its call site as above. Effect cancellation reaches the native Fetch transport.

## Tracing

The Team visual-answer runtime supplies `Jev.observedLayer` and a Raindrop observer at its owning Durable Object boundary. This preserves native decision results, failures and cancellation while sending bounded background telemetry. Use the observed layer rather than `layer` when adding a traced workflow; the workflow must supply exact correlation and an owning background lifetime. See [Raindrop collection and limits](/operations/raindrop#jev-decisions) for exported fields and exclusions.

## Reference choices

The implementation uses [`@effect/ai-typesafe`](https://github.com/Effect-TS/effect/tree/main/packages/ai/typesafe) pinned to `4.1.2`, matching Workbench's Effect version. This native provider supplies schema-validated decisions, redacted credentials and Effect HTTP integration without a custom Promise adapter. These provider APIs are marked unstable; upgrade them with Effect and verify against the installed types.

Other projects reviewed:

- [TypeSafe's official JavaScript SDK](https://github.com/typesafe-ai/typesafe-sdk-js) and [official quickstart](https://docs.typesafe.ai/introduction/quickstart): the direct API and SDK reference.
- [effective-jev](https://github.com/stoopid-computers/effective-jev): an independent Effect fork whose reviewed `0.0.4` manifest requires Effect `4.0.0-rc.112`; not a dependency here.
- [discern](https://github.com/doeixd/discern): higher-level decision policies built on Effect's `DecisionModel`; useful reference for later behavior, unnecessary for configuration.
- [json-render's Jev integration](https://json-render.dev/docs/jev): experimental UI composition, separate from this provider setup.

No new Alchemy provider or hosted resources are needed. Existing Worker secret and environment bindings supply the native Effect provider. Response admission and display composition remain separate workflows. Missing or invalid Jev configuration keeps automatic response decisions quiet and preserves explicit @Wes activation.

## Evaluate response invitations

The response evaluation compares structural reply-to-Wes rules with one invitation Noul and a three-question version that also checks human-directed messages and requests for silence. It uses 24 invented exchanges, with provisional labels for a narrow follow-up policy and a broader open-help policy. See the [evaluation commands](/reference/cli#jev-response-evaluation).

The default run is offline and requires no key. Explicit live evaluation sends only these built-in examples to Jev. It never loads application conversations, starts Wes, invokes tools, changes response preferences or publishes replies. The CLI caps state at eight preceding messages of at most 2,000 characters each and uses at most two concurrent requests, twelve seconds per decision and three minutes overall, without automatic retries. These are evaluation limits, not settled live-chat policy.

Reports retain the requested model, returned identifiers when available, probabilities, token usage, latency and unavailable outcomes. The pinned TypeSafe provider 4.1.2 does not forward the response model identifier, so the returned version is currently unknown; pin `JEV_MODEL` for these comparisons. Candidate thresholds are compared separately; none is connected to application admission. Missed invitations include abstentions and unavailable decisions, so failures cannot silently improve recall. Estimated cost covers answered requests with known token counts and a verified rate for the returned or explicitly requested version. The report identifies when the estimate uses the requested version because returned metadata is unavailable. An unversioned alias without returned metadata receives no estimate.

Synthetic labels are not approved product policy or production accuracy. Review failures and collect human judgments before expanding the bounded Team response policy. Explicit @Wes activation remains independent of this evaluation.

### Initial synthetic findings

On November 24, 2026, both policies were evaluated against all 24 examples using the explicitly requested `jev-1.14.0`: 96 requests across the single and focused approaches, all answered. The labels remain provisional. The narrow policy has nine positive invitations; open-help has eleven.

| Approach and policy | Candidate threshold | Unwanted replies | Missed invitations |
| --- | --- | --- | --- |
| Reply-to-Wes rule, narrow | None | 2 | 2 of 9 |
| Single Noul, narrow | 0.70 | 1 | 1 of 9 |
| Single Noul, narrow | 0.90 | 0 | 4 of 9 |
| Focused questions, narrow | 0.80 | 0 | 4 of 9 |
| Single Noul, open-help | 0.70 | 0 | 1 of 11 |
| Focused questions, open-help | 0.70 | 0 | 1 of 11 |

The structural rule replied to thanks and a stop request, while missing an unthreaded answer and a natural address to Wes. The narrow single-question gate sometimes treated an open question to the room as an invitation despite the selected policy. Higher thresholds prevented that interruption in this sample while missing clear answers to Wes. Additional veto questions did not consistently improve the trade-off.

Median request latency across the four groups was 103–119 ms; group p95 values were 133–229 ms. Reported input usage totaled 60,316 tokens. At TypeSafe's [published rate](https://docs.typesafe.ai/models) for the requested version, the estimated input charge is about $0.0025; returned model metadata and actual billing were not verified.

These results do not establish production accuracy or calibrated thresholds. The app now evaluates every eligible unmentioned message from an opted-in member with multiple focused questions; its agreed participation and native delivery policy is documented in [Team responses](/architecture/team-agent#replies-without-mentions). The older evaluator remains a synthetic comparison, not a complete test of the current app policy. Collect more human-labeled cases, including a held-out set, before enabling the behavior by default.
