.md URL) into your coding agent’s context, or copy the prompt below.
Add Tenet Guardrails to this codebase
Decision procedure
- Is the harness LangChain (
create_agent/langchain>=1.2.13)? → UseTenetJudgeMiddleware. Installtenet-langchain. - Is it Python but not LangChain? → Use
@judgedon tool functions, orevaluate()at the dispatch choke point. Installtenet-client. - Not Python? → Call the HTTP API directly:
POST https://judge.tenetlabs.com/decidewithAuthorization: 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
JudgeUnavailableErrorand 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), orTENET_CLIENT_ID+TENET_CLIENT_SECRETif 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
surfaceper 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 toresume_triage(the default) for unmapped tools. Hardwiring one surface for all traffic is the canonical integration mistake — see Surfaces. - Populate
context.recruiter_promptwith the user’s verbatim ask (required for full safety-pattern coverage) andcontext.candidate_contentwith the resume/candidate text whenever the action involves one (omitting it disables candidate-side protections). The SDK derivesrecruiter_promptfrom a stringtool_inputautomatically; 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 incontext=; the judge evaluates those.tool_namealone 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_idandprior_user_turnswhen 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_mson 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 asreview(ageguard,tool_pre) and the tool is not executed. - A
revieweither 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, orTENET_CLIENT_SECRETfor M2M), side-effectful tools refuse to run (fail-closed path works). - Tools of different action kinds send different
surfacevalues — a job-ad drafting call must not go out asresume_triage. Grep the integration for a single hardwiredsurfaceand fix it if found. -
context.recruiter_promptcarries the user’s actual ask on every judged call;context.candidate_contentis populated when the action involves a resume. - Tool-phase calls carry
tool_input(andtool_descriptionincontext=where the tool has legal or policy preconditions) — routine tool calls routing to a human is the symptom of omitting them. -
session_idis 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
Links
- Quickstart — human-paced version of this page
- Policies — full action vocabulary
- API Reference — wire schemas for non-Python integration