Skip to content

Build

Adapter contract, state, policy gate and failure handling

Build one reusable decision service before creating several Microsoft integrations. Change provider details without rebuilding every flow.

Proposed design

Request order

  1. Receive the event; verify caller and record permissions.
  2. Retrieve the minimum evidence; reject missing or stale required fields.
  3. Call Jev with pinned model and question versions.
  4. Validate the response shape, labels and probabilities.
  5. Apply deterministic policy (confidence threshold + reversibility).
  6. Create a route or review task; record the later human outcome.

Keep the prediction and final action as separate records.

State before questions

A clear question cannot compensate for missing evidence. Define the fields needed for the decision, their sources and how fresh they must be. Retrieve under the caller’s permissions. Exclude unrelated history unless it improves measured performance. Jev accepts text, JSON objects and arrays of text—not raw image, audio or video. Put OCR and retrieval before the decision layer.

Policy gate

Jev’s confidence summarises how its probabilities are spread. It is not permission to act. Your code should apply at least two tests:

TestRuleRoute if it fails
ConfidenceAnswer confidence meets the threshold set for this actionHuman review
ReversibilityThe action can be undone without harmHuman review, always

Set thresholds on held-out labelled cases and the cost of a wrong action. Placeholder values in demos (for example 0.75) are not production settings.

Validation and idempotency

Check required fields, allowed labels, numeric ranges and expected structure. Reject incomplete results rather than filling them with permissive defaults. Use a durable idempotency key from item ID and decision-policy version. Choose one layer to own retries with a deadline and circuit breaker; do not multiply flow retries with adapter retries.

Failure handling

  • Unknown or unexpected destinations → default review branch.
  • Timeouts and unavailable dependencies → review item with correlation ID.
  • Hostile instructions in content → treat as evidence, never as authority to change policy.
  • Circuit open → agreed fallback with capacity planning for the review queue.

Do not use early demonstrations to send refunds, change access or publish customer messages.

Direct experiment call (development only)

POST https://api.typesafe.ai/v1/systemone
Authorization: Bearer <secret supplied at runtime>
Content-Type: application/json

{
  "model": "jev-1.13.0",
  "state": {"text": "My invoice shows the wrong service"},
  "questions": {
    "route": {
      "type": "choice",
      "instructions": "Which team should first review this ticket?",
      "criteria": {
        "billing": "Invoice or billing questions",
        "technical": "Service faults or technical help",
        "review": "Other or insufficient evidence"
      }
    }
  }
}

Supply the bearer credential through a secure connection. Do not put it in an agent prompt or a shared flow definition. Official fields: docs.typesafe.ai.