Skip to main content
This page is written for you, the model. If you are running it as a prompt, your goal is to add Tenet Guardrails to the harness in front of you, then prove they work with the verification checklist at the end. Everything needed is on this page — no other docs required. Humans: paste this page (or its .md URL) into your coding agent’s context, or copy the prompt below.

Add Tenet Guardrails to this codebase

Or hand the whole page to Claude Code from the harness repo:

Decision procedure

  1. Is the harness LangChain (create_agent / langchain>=1.2.13)? → Use TenetJudgeMiddleware. Install tenet-langchain.
  2. Is it Python but not LangChain? → Use @judged on tool functions, or evaluate() at the dispatch choke point. Install tenet-client.
  3. Not Python? → Call the HTTP API directly: POST https://judge.tenetlabs.com/decide with Authorization: Bearer $TENET_API_KEY. See API Reference.

Invariants — do not violate

  • Never register the judge as a model-callable tool. A model can choose not to call a tool; middleware, decorators, and dispatch-loop gates run unconditionally. A guardrail the model can skip is not a guardrail. Wire the judge around tools, never as one.
  • Fail closed for side effects. If the judge is unreachable, tools that write, send, or post must not run. Catch JudgeUnavailableError and stop the call. Failing open is permitted only for read-only tools, and must be logged.
  • Construct one client per process, at startup, then warmup(). Never construct per request.
  • Credentials come from env: TENET_API_KEY (from platform.tenetlabs.com), or TENET_CLIENT_ID + TENET_CLIENT_SECRET if Tenet issued M2M credentials. Set one or the other, not both. Never hardcode, commit or log them. If neither is set, ask the user for a key.
  • Set surface per request, never per application. The surface names the recruiting action being judged — resume_triage (screening/filtering), job_ad_drafting, candidate_ranking, interview_question_gen, candidate_outreach — and the judge reads it to frame the ask. Map tool names to surfaces; fall back to resume_triage (the default) for unmapped tools. Hardwiring one surface for all traffic is the canonical integration mistake — see Surfaces.
  • Populate context.recruiter_prompt with the user’s verbatim ask (required for full safety-pattern coverage) and context.candidate_content with the resume/candidate text whenever the action involves one (omitting it disables candidate-side protections). The SDK derives recruiter_prompt from a string tool_input automatically; dict inputs should carry the keys explicitly.
  • On tool phases, send the facts of the call — not its name. Pass the arguments you’re about to call with as tool_input, and what the tool requires (tool_description) and any lawful-basis facts in context=; the judge evaluates those. tool_name alone moves no verdict, and no caller-asserted field exempts a call — caller signals can tighten a guardrail, never loosen one. Say what the action is for — the role, the process stage, the consent basis — so the judge can evaluate it. See Tool context.
  • Field casing is snake_case on the wire and in the SDK (tool_name, session_id, risk_labels). Don’t camelCase.
  • Show a clear message, never a stack trace. Use the verdict’s reason (the finding’s evidence), else a fixed fallback string.
  • Pass session_id and prior_user_turns when the harness is conversational — single-call judging misses multi-turn risk.

Canonical integration (LangChain)

Canonical integration (non-LangChain Python)

review is where a human comes in. This harness holds the call; a LangGraph harness can pause the run with interrupt() and resume on approval — see Human-in-the-loop review. Mirror the same call with phase="tool_post" and tool_output= after execution when tool output re-enters model context.

Verification checklist

After integrating, confirm each item by running the harness:
  • A benign tool call succeeds and is judged (latency_ms on the response shows the added time).
  • A violating call doesn’t run — test input: a resume search for "5+ years Python, must be under 30" comes back as review (age guard, tool_pre) and the tool is not executed.
  • A review either holds the call or pauses for a person, per the harness’s choice — never proceeds silently.
  • The message shown to the model/user comes from the verdict’s reason, not a stack trace.
  • With the credential unset or wrong (TENET_API_KEY, or TENET_CLIENT_SECRET for M2M), side-effectful tools refuse to run (fail-closed path works).
  • Tools of different action kinds send different surface values — a job-ad drafting call must not go out as resume_triage. Grep the integration for a single hardwired surface and fix it if found.
  • context.recruiter_prompt carries the user’s actual ask on every judged call; context.candidate_content is populated when the action involves a resume.
  • Tool-phase calls carry tool_input (and tool_description in context= where the tool has legal or policy preconditions) — routine tool calls routing to a human is the symptom of omitting them.
  • session_id is stable across one conversation and changes across conversations.
  • No credentials appear in code, logs, or version control.
  • The test calls are listed on Decision traces at platform.tenetlabs.com, under the account that owns the key. Ask the user to check; don’t sign in on their behalf.

Key facts