tenet-openai-agents
Tenet Guardrails for the OpenAI Agents SDK.
It judges the user's prompt, every function tool call (before and after it runs) and the final
reply with the Tenet judge. It uses the Agents SDK's own guardrail hooks and is built on
tenet-client.
pip install tenet-openai-agents
export TENET_API_KEY="sk_tenet_..."
Quickstart
from agents import Agent, Runner, function_tool
from tenet_client import TenetCloudJudgeClient
from tenet_openai_agents import TenetGuardrails
judge = TenetCloudJudgeClient.from_env() # once per process
judge.warmup()
tenet = TenetGuardrails(judge)
@function_tool
def search_resumes(query: str) -> str:
"""Search the resume database."""
...
agent = tenet.protect(Agent(name="Recruiter", tools=[search_resumes]))
result = await Runner.run(agent, "find senior Python engineers in NYC")
protect() returns a copy of the agent, and of every agent it hands off to, with four guardrails
attached. It does not modify your agent or tool objects:
| Agents SDK hook | Tenet phase | Held outcome (block, review, judge down) |
|---|---|---|
input_guardrails |
agent_input |
InputGuardrailTripwireTriggered; the model is never called |
tool_input_guardrails |
tool_pre |
the tool does not run; the model reads the reason and can recover |
tool_output_guardrails |
tool_post |
the output is withheld; the model reads the reason instead |
output_guardrails |
agent_output |
OutputGuardrailTripwireTriggered |
Outcomes and defaults
The judge returns a verdict, and you choose what each outcome does. The defaults fail closed:
TenetGuardrails(
judge,
on_block="reject", # tool call/output replaced with the reason the model reads
on_review="reject", # held, never silently allowed
on_unavailable="raise", # judge unreachable or timed out: halt the run
surface_by_tool={ # the recruiting action each tool performs
"send_outreach": "candidate_outreach",
"rank_candidates": "candidate_ranking",
},
session_id=lambda ctx: ctx.conversation_id, # from the context= you pass Runner.run
run_input_in_parallel=False, # True: overlap the judge with the first model call
)
For each outcome, "reject" keeps the run going with a message to the model, "raise" raises
ToolInputGuardrailTripwireTriggered or ToolOutputGuardrailTripwireTriggered, and "allow" lets
the call through. Agent-level guardrails trip on any outcome that is not "allow". A
caveat verdict is an allow whose note is in output_info.caveat.
Every guardrail result has a TenetGuardrailInfo as output_info, with the kind, reason, rule IDs,
severity and decision_id (the ID Tenet support asks for). Catch a tripwire to show the reason:
from agents import InputGuardrailTripwireTriggered
try:
result = await Runner.run(agent, user_message)
except InputGuardrailTripwireTriggered as e:
info = e.guardrail_result.output.output_info
print(f"Held ({info.kind}): {info.reason}")
Wire it yourself
Use this to guard some tools and not others, or to control guardrail order:
@function_tool(
tool_input_guardrails=[tenet.tool_input_guardrail],
tool_output_guardrails=[tenet.tool_output_guardrail],
)
def send_email(to: str, body: str) -> str: ...
agent = Agent(
name="Recruiter",
tools=[send_email],
input_guardrails=[tenet.input_guardrail],
output_guardrails=[tenet.output_guardrail],
)
Gotchas
- Only function tools can carry tool guardrails. Hosted tools (web search, file search, code
interpreter, computer use), tools from
mcp_serversandHandoffobjects cannot.protect()raisesTypeErrornaming them; passstrict=Falseto run them unguarded on purpose. agent.as_tool()is guarded as a tool, but the inner agent is not. Callprotect()on the inner agent before you convert it.- The input guardrail runs before the model by default. Parallel mode saves the judge's latency. The cost is that the first model call, and its tokens, start before the verdict.
- The input guardrail only runs on the first agent of a run, and the output guardrail only on the last. This is Agents SDK behavior. Tool guardrails run on every guarded tool, whichever agent calls it.
- Construct the judge client once. It holds the token cache and connection pool.
Tested against openai-agents 0.25.x and 0.26.x and tenet-client 0.7.7+.
Metadata
Release files for tenet-openai-agents 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tenet_openai_agents-0.1.0.tar.gz | 12.2 kB | With provenance | Details for tenet_openai_agents-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tenet_openai_agents-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tenet_openai_agents-0.1.0-py3-none-any.whl |
Total release size: 25.2 kB
Release files / tenet_openai_agents-0.1.0.tar.gz
| Download URL | tenet_openai_agents-0.1.0.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4de9574844e5c1806f803470a92d398dc25cd378611047ca824a63e2eeb48db3
|
|
BLAKE2b-256 checksum How to use checksums |
9c490dd704d685d33468c8811c625504650c9d8de17bbe5669fec87efe627c8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logRelease files / tenet_openai_agents-0.1.0-py3-none-any.whl
| Download URL | tenet_openai_agents-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
351a334a1b1d95273efe3be0c22aff3cf324833c5f0ae8a6fe1ca9981f74c666
|
|
BLAKE2b-256 checksum How to use checksums |
4eceb3af72862b64bb766765d9b8e99c353fcfb8206b898be81fef4c5d5fecd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logSecurity for tenet-openai-agents 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for tenet_openai_agents-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.