> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tenetlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Verdict-first streaming

> POST /decide/stream sends the verdict as its first content event, ahead of PII and safety findings — block at verdict, allow side effects only at done.

**Verdict-first streaming**: `POST /decide/stream` → SSE events in a locked order, with `verdict` as the first event after the ACK. Your harness can block the moment `verdict` lands; findings and the final envelope follow behind it.

## When to use it

The stream's `verdict` event fires as soon as the EEO decision is made. A sync `/decide` call also waits for the remaining work — enforcing safety findings are merged before the response is sent. Streaming lets a user-visible interaction react to a block without that wait.

The gain is the gap between the EEO decision and the merged response, not the judge's own time — both endpoints wait for the same judge call. Use streaming when your harness blocks a user-visible interaction on the verdict and already handles SSE. Skip it when you're judging in a background queue — the non-streaming `evaluate()` is simpler there.

## SDK

```python theme={null}
# Python — async-only; streaming requires the async client path.
async for event in judge.evaluate_stream(
    phase="tool_pre",
    tool_name="search_resumes",
    tool_input={"query": "find recent grads"},
):
    if event.event_type == "verdict":
        if event.data["verdict"] in ("exclude", "route_to_human"):
            break  # block now — blocking early is always safe
    elif event.event_type == "done":
        final = event.data["verdict_final"]  # allow side effects only on this
```

Want the stream without event handling? `evaluate_stream_to_response(...)` drains the stream and returns an aggregated `CloudJudgeResponse`. In the LangChain middleware, pass `stream=True`: it reads the stream through to `done` and dispatches your policy once, on the complete response, not at the `verdict` event. To block at `verdict`, consume `evaluate_stream` yourself as above.

## Event order

Events arrive in a locked sequence. `verdict` is always the first event after `request_accepted`:

```text theme={null}
request_accepted → verdict → [pii_findings] → [verdict_revised]
  → explanation_chunk* → rewrite_chunk* → [safety_findings] → done
```

| Event | Payload | Notes |
| - | - | - |
| `request_accepted` | `canonical_id`, `trace_id` | Correlation IDs — log them. `canonical_id` is the same value as the sync body's `decision_id` |
| `verdict` | `verdict`, `severity`, `primary_risk`, `risk_labels`, `provisional` | The EEO decision. `risk_labels` is the full label list (parity with the sync `/decide` findings); `primary_risk` is the single derived label |
| `pii_findings` | `findings: [...]` | Emitted when PII is detected. Arrives **after** `verdict` |
| `verdict_revised` | new verdict, `risk_labels`, `previous_verdict`, `reason` | An enforcing safety finding outranked the EEO verdict — see below |
| `explanation_chunk` | `chunk` | Part of the locked order; the current judge doesn't emit it |
| `rewrite_chunk` | `chunk` | Part of the locked order; the current judge doesn't emit it |
| `safety_findings` | `findings: [...]` | Per-domain safety findings (disclosure, injection, exfil). Arrives before `done`, or as one event just **after** `done` — handle both |
| `error` | `code`, `message`, `retry` | `retry: true` → retransmit; `false` → fail closed |
| `done` | `verdict_final`, `envelope` | Stream complete. `envelope` is byte-equivalent to the sync `/decide` response body. `verdict_final` always equals the post-merge top-level verdict |

Treat any event type you don't recognize as opaque and keep reading until `done`.

## Revised verdicts

The judge's verdict is final when it reaches the wire — `provisional` is `false` today. The `verdict` event still isn't the whole story: it carries the EEO decision, and an enforcing safety finding (an exfil or injection guard, say) that is more restrictive can still outrank it. The stream then sends `verdict_revised`, and `done.verdict_final` carries the merged result.

> [!WARNING]
>
> Acting on `verdict` alone is the streaming footgun: an `include` at `verdict` can become a block at `verdict_revised`. Safe pattern — block at `verdict` (blocking early is always safe); allow a side-effectful call only at `done`, on `verdict_final`.

`provisional: true` is reserved — the current judge doesn't send it on this endpoint. If it appears, `TenetJudgeMiddleware` waits for the final verdict before dispatching your policy.

## Raw SSE

```bash theme={null}
curl -N https://judge.tenetlabs.com/decide/stream \
  -H "Authorization: Bearer $TENET_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"surface": "resume_triage", "messages": [{"role": "user", "content": "find recent grads"}], "context": {"recruiter_prompt": "find recent grads"}}'
```

The stream endpoint takes the same envelope as `/decide` — including [`surface`](https://docs.tenetlabs.com/concepts/surfaces), chosen per request (a screening ask here, hence `resume_triage`) — except `mode: "guardrails"`, which returns `400`.

```text theme={null}
event: verdict
id: 1003
data: {"verdict": "include", "severity": "none", "primary_risk": "none", "risk_labels": [], "provisional": false}

event: done
id: 1009
data: {"verdict_final": "include", "envelope": {"verdict": "include", "severity": "none", "latency_ms": 290, "decision_id": "0123456789abcdef0123456789abcdef", "findings": [{"domain": "eeo", "verdict": "include", "severity": "none", "enforcement": "enforce", "rule_ids": [], "risk_labels": [], "evidence_span": null}]}}
```

The aggregated stream — what `evaluate_stream_to_response()` returns and what the `done.envelope` field carries — is byte-equivalent to the sync `/decide` response body. Per-domain detail is read off `done.envelope.findings`, not separate stream events. See [Multi-verdict responses](https://docs.tenetlabs.com/concepts/multi-verdict.md).

## Links

* [How the Judge decides — decision paths](https://docs.tenetlabs.com/concepts/decisions.md#decision-paths)
* [LangChain middleware — `stream=True`](https://docs.tenetlabs.com/guides/langchain)
* [API Reference — stream endpoint](https://docs.tenetlabs.com/api-reference/introduction.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.