Skip to main content
tenet-client: framework-agnostic Python client for the Judge API. Pure Python + httpx + pydantic — no LangChain dependency. Python 3.11–3.13.

TenetCloudJudgeClient

Pass api_key, or client_id and client_secret. Passing both, neither, or a key that doesn’t start with sk_tenet_ raises ValueError. See Authentication. TenetCloudJudgeClient.from_env() reads the same options from TENET_* environment variables — the full table is in Authentication. Prefer from_env(); constructor args are for tests and multi-tenant processes.

Methods

Evaluation parameters

All evaluate* methods take the same keyword-only parameters:
str
required
Where in the agent loop: "agent_input" | "tool_pre" | "tool_post" | "agent_output".
str
default:""
Tool being gated. Used by per-tool policies and audit logs.
Any
default:"None"
Tool arguments (tool_pre) — any JSON-serializable value. The wire envelope’s context.recruiter_prompt is derived from it: a str passes through verbatim; other shapes are JSON-serialized, which is not the user’s words. To control what the judge reads — and to supply context.candidate_content when the action involves a resume — pass a dict carrying those keys: tool_input={"recruiter_prompt": user_ask, "candidate_content": resume_text}. Why these fields matter.A dict tool_input is also sent as the top-level tool_input wire field, which isn’t rendered to the judge — where to put content you need judged. Any other facts the judge should read go in context=.
dict[str, Any] | None
default:"None"
Request-level facts for the judge to read — role, stage, consent flags, a job description, a scorecard — as a flat dict merged into the wire context. Only recruiter_prompt and candidate_content are read from tool_input; anything else the judge must read goes here. Keys must be strings and values JSON-serializable; the reserved keys tool_input, tool_output, recruiter_prompt, candidate_content, tool_name, surface, phase, intent, and workflow raise ValueError — use their own arguments. Per call; no client-level default. Tool context.
Any
default:"None"
Tool return value (tool_post). Sent as a role: "tool" message after the user’s turn, which the judge reads as untrusted content — an instruction inside a tool result is treated as a possible injection, not as the user’s request. It is never merged into context, so a tool’s return value can’t set a context key the judge reasons over (role, candidate_content, …). If you need a value from the output as context, pass it in context= yourself.
list[str] | None
default:"None"
Third-party text that isn’t the judged tool’s return value — resume bodies, candidate messages, fetched pages, other API responses. Each entry is sent as its own role: "tool" message, the same untrusted channel as tool_output.
str | None
default:"None"
The agent’s own reply, to check what it said before your user sees it. Only valid with phase="agent_output"; any other phase raises ValueError. Sent as the last message, role: "assistant": the judge reviews that message and reads everything before it (the user’s ask in tool_input, retrieved_content, tool_output) as context. Don’t send the reply as candidate_content or tool_output. Those channels mean text someone else wrote and are judged as untrusted, so your agent’s own next steps read as an injection. Pass the user’s ask as well: the judge holds fewer lawful replies when it can see what the reply answers. Reply checks are enabled per account; contact Tenet to turn them on. Added in 0.7.6.
str | None
default:"None"
What the user asked, sent separately from the tool’s arguments. The judge reads it as the request. Passing a different value than a recruiter_prompt key inside tool_input raises ValueError. Added in 0.7.7. The user’s ask.
str | None
default:"None"
Text written by the person the decision is about. Never the agent’s reply, which is agent_reply=. Passing a different value than a candidate_content key inside tool_input raises ValueError. Added in 0.7.7.
float | None
default:"None"
Wall-clock bound on the whole call, in seconds. Overrides the client’s deadline. Exceeding it raises JudgeTimeoutError. Added in 0.7.7. Deadlines and outages.
bool
default:"True"
Pass False for calls that only observe, so they neither take the breaker’s probe slot nor count toward it. Added in 0.7.7. Deadlines and outages.
str | None
Conversation ID. Groups evaluations into one audit trace. Max 199 chars.
list[str] | None
Prior user messages, oldest first — gives the judge multi-turn context.
str | None
"resolved" | "unresolved" | "error" — whether the tool output settled the request.
str | None
default:"None"
Caller-asserted classification of the call, emitted as the top-level intent wire field — the service’s highest-precedence intent signal, recorded on the decision trace (the current judge doesn’t change verdicts on it). "read" (non-actuating lookup) | "action" (mutating/actuating) | "unknown" (== None — omitted from the body). An out-of-vocab value raises ValueError at the client boundary. Present on evaluate / evaluate_async / evaluate_stream / evaluate_stream_to_response / evaluate_phase[_async], and sets CloudJudgeRequest.intent. Safety: "read" is authoritative only at phase="tool_post", where the tool’s read-only nature is verifiable — see the read-intent contract. In tenet-langchain, prefer declaring the read taxonomy once with read_tools= rather than passing intent= per call.
str | None
What kind of recruiting action this call checks: "resume_triage" | "job_ad_drafting" | "candidate_ranking" | "interview_question_gen" | "candidate_outreach". Overrides the client default — set it per call from the user’s current intent (a tool → surface map is usually enough); don’t let one hardwired value judge all your traffic. Surfaces.
str | None
default:"None"
Trace-only label naming which of your integrations made the call — "resume-screener" vs "recruiter-agent" — so your account’s traffic filters per workflow on the trace. Lowercase slug (^[a-z0-9][a-z0-9._-]*$), at most 64 chars; a bad value raises ValueError before the request is sent. Overrides the client / TENET_WORKFLOW default per call, the same resolution as surface. Never read by the judge and never affects the verdict — distinct from surface, which the judge reads. Sent only when set.
str | None
Distributed-trace correlation. Also: parent_span_id, metadata: dict, timeout: float.

CloudJudgeResponse

Per-domain rule_ids, risk_labels, and evidence_span live on each findings[] entry. Code that branches only on verdict.decision (or the top-level verdict + severity) is safe by construction — the merge guarantees an enforcing domain’s restrictive verdict shows up at the top level. A safety finding decomposes into a per-detector sub_findings list of SubFinding (exported from the package): sub_domain ("injection" | "exfil"), verdict, severity, enforcement, rule_ids, evidence_span. Read it to attribute a safety block to the exact guard that fired — non-decomposing domains (EEO, PII, …) leave sub_findings empty.

Consuming multi-verdict findings

tenet-client ships parsing helpers so you don’t hand-roll the array walks:
An integration that branches only on verdict.decision is still safe by construction — the merge rule guarantees an enforcing domain’s restrictive verdict shows up on the top level. The helpers are for the cases where you want per-domain audit logs, domain-specific UX, or visibility into audit-only signals. Full rules: Multi-verdict responses.

Policy types

JudgePolicy, JudgeVerdict, JudgeContext, and JudgeAction are covered in depth in Policies. Quick shape:
  • JudgeVerdict.decision is the four-way allow | caveat | review | block (built from CloudJudgeResponse via from_cloud_response — the exact native-verdict mapping is in How the Judge decides). caveat is the non-blocking advisory tier (include_with_caveats) — it dispatches to on_caveat, never on_review. JudgeVerdict also surfaces route_reason, degraded, and the advisory caveat string when present.
  • JudgeVerdict.findings is the per-domain identifiers promoted to dicts: [{"rule_id": "EEO-AGE-PROXY-01"}, ...] — read the whole normalized list with JudgeVerdict.finding_labels, or extract per-entry with f["rule_id"]. Each rule_id is the per-finding code (what RiskLabelDisplay / topic mappers key on), falling back to the risk_labels phrase only when no code is present. JudgeVerdict.severity drops the operator-only info level to None.
  • JudgeAction factories: allow, block, tool_error, retry_nudge, retry_nudge_from_verdict, human_review (a passthrough marker — the callback itself must pause the run), override_input, override_output, raise_error.
  • JudgePolicy(per_tool={...}, per_phase={...}) nests full policies; most specific wins.

The user’s ask: user_prompt= and candidate_content=

Without these, the only way to tell the judge what the user asked was to tuck it inside tool_input under a magic key. At a tool phase, pass what the user asked separately from the tool’s arguments. The judge reads the ask from user_prompt=; the arguments stay in tool_input:
candidate_content= is text written by the person the decision is about (never the agent’s reply, which is agent_reply=). Passing a different value than a recruiter_prompt / candidate_content key inside tool_input raises ValueError.
These arguments change what the judge reads, so they can change verdicts. Try them in a test environment and compare before you turn them on in production.

Support correlation and degraded answers

Every response carries decision_id, and so does the JudgeVerdict your policy callbacks receive (verdict.decision_id, verdict.canonical_id; None when the engine sent none). Log verdict.decision_id from on_block / on_review and you have the id support asks for. Never show it to the end user. When the engine cannot reason about the content (for example a tripped breaker answers route_to_human), the response says so with degraded or route_reason == "infra_degraded". resp.is_degraded and verdict.is_degraded fold both into one check. Treat a degraded answer as “no answer”, not as a finding about the content. A timeout raises JudgeTimeoutError, a subclass of JudgeUnavailableError, so existing except JudgeUnavailableError blocks keep working. With evaluate_phase / evaluate_phase_async (and @judged given a policy), a timeout reaches JudgePolicy.on_timeout and every other judge failure reaches on_unavailable. If you never set on_timeout, timeouts go to on_unavailable, so failing open with only on_unavailable=... still covers timeouts. Set on_timeout only when timeouts need different behaviour. judge.workflow and judge.judge_id expose the client’s configuration read-only.

Deadlines and outages

timeout bounds each HTTP operation (the token mint, the request, each stream read), so one call can take about twice that or more. deadline bounds the whole call in wall-clock seconds: set it on the client (deadline=2.0, or TENET_JUDGE_DEADLINE_SECONDS) or per call (judge.evaluate(..., deadline=1.0); the per-call value wins). Exceeding it raises JudgeTimeoutError, so it reaches on_timeout. On evaluate_stream the deadline runs from the first call to exhaustion, but only the client’s own waits are bounded: a consumer that is slow between events is never cancelled, and the next read raises. Unset means no deadline. A CircuitBreaker makes a sustained outage cost one probe per cooldown instead of a full timeout per call:
After three consecutive failures the breaker opens and calls raise JudgeCircuitOpenError (a JudgeUnavailableError, so on_unavailable handles it) without touching the network. After the cooldown one call is let through as a probe; its success closes the breaker, its failure reopens it. A timeout, a 5xx, a 408 or 429, or a network error counts as a failure, and so does a response with is_degraded, which is still returned to you. A timeout from a per-call deadline shorter than the client’s own says nothing about the judge and is not counted. The breaker is process-local; one instance can be shared by several clients to trip them together. An HTTP 4xx other than 408 and 429 (a malformed request, a rejected key) is a bug on your side, not a sick judge, so it neither opens the breaker nor closes it; a probe that ends that way frees the slot and the breaker stays open for the next probe. JudgeUnavailableError.status_code carries the HTTP status when there was one. If the stream’s verdict already arrived, a deadline that expires afterwards still raises JudgeTimeoutError but is not counted as a failure. Calls that only observe (a shadow check next to enforcing calls on the same client) pass record_breaker=False: they reach the network only while the breaker is closed, are rejected with JudgeCircuitOpenError while it is open or half-open (they never take the probe slot), and record neither a success nor a failure, so a fault seen only by observers cannot fail a real call.

Check a piece of text

check() judges one phase and returns a JudgeOutcome instead of raising. It is for code that just needs “may I send this?”:
Any judge failure (timeout, open breaker, HTTP error, anything unexpected) becomes kind="unavailable"; a wrong argument still raises. If the engine answers without judging (out.degraded), the default treats it as unavailable so fail_mode applies. Pass degraded_as="verdict" to map the engine’s fallback verdict instead, usually review, which asks a human rather than sending unreviewed (open) or refusing with no override (closed). Degraded and unavailable outcomes are never cached. check_async is the async twin. check() validates its arguments against TenetCloudJudgeClient.evaluate_async itself, so a wrong argument raises ValueError even when your client is wrapped, mocked or traced.

Decide per finding

The merged top-level verdict can be driven by a domain you do not act on (a pii finding on a hiring flow), and audit_only findings never gated anything. classify_findings reads the individual findings instead and maps them onto your own tier names:
An unknown severity string ranks above critical (and logs a warning), so a vocabulary change in the engine lands in your strictest tier rather than passing. summarize_findings returns the counted findings, the top one, its rule_ids and evidence_span, and at_least("high").

Record every decision

A DecisionRecord is one normalized line per judge decision (decision, native verdict, outcome, severity, rule_ids, decision_id, trace and session ids). A sink is any Callable[[DecisionRecord], None]; a sink that raises is logged and never reaches your call.
The Langfuse sink writes a tenet_judge score whose value is the outcome and whose comment is the record as JSON. It needs only an object with create_score, so Langfuse is not a dependency, and it skips records that have no trace id. Pass them to check as on_decision=sinks: one record per call that reached the judge (a cache hit emits none).

Testing your integration

tenet_client.testing gives you a real client over an in-memory transport: no network, no credentials, the token handshake answered for you. Build bodies with decide_response / finding, and test your own policy callbacks through evaluate_phase:
responses can also be a sequence (answered in order, the last repeats) or a callable that receives each parsed request body. Other options: captured=[] collects every request body, status=503 and raises=httpx.ReadTimeout("slow") simulate outages, delay_s= simulates a slow judge, and use_stream=True is served as a verdict-first stream.

@judged

Wraps sync or async functions. Raises JudgeBlocked (.reason, .tool_name, .phase, .judge_id) on block. @judged sends the client’s surface on every call — there’s no per-call override on this path. If your tools span action kinds (screening vs. drafting vs. outreach), gate them with evaluate(surface=...) at your dispatch loop instead — the tool → surface map.

Local-server exports

The package also ships TenetClient, its request and response models (EvaluateRequest, DetectResponse, RedactResponse, …), and TenetConnectionError / TenetViolationError — these talk to a local Tenet server (PII detect/redact), a separate product from the cloud judge. If you’re integrating judge.tenetlabs.com, ignore them; TenetCloudJudgeClient is your client.

Exceptions