Skip to main content

Earned autonomy for the OpenAI Agents SDK — warrantd drives the approval switch.

Project description

warrantd-openai-agents

Your framework has the approval switch; warrantd is the brain that flips it.

The OpenAI Agents SDK already ships human-in-the-loop tool approval: needs_approval, interruptions, approve/reject, resume. What it doesn't ship is a policy for when a tool needs approval — that's usually a hardcoded bool.

This adapter makes the switch dynamic: earned autonomy from warrantd. A tool starts at MANUAL (every call interrupted for a human), earns SUPERVISED through clean approvals (auto-runs within a value cap), and is bounded by ceilings no metric can move.

pip install warrantd-openai-agents

Quickstart

from decimal import Decimal
from agents import Agent, Runner
from warrantd import (
    ActionClass, ApprovalHistorySignal, AutonomyState, GraduationThresholds,
    InMemoryApprovalHistory, RiskTier, TrustLayer, TrustPolicy,
)
from warrantd_openai_agents import ToolBinding, WarrantdGate

policy = TrustPolicy(
    actions={"issue_refund": ActionClass(
        name="issue_refund", risk=RiskTier.REVERSIBLE_WRITE,
        auto_cap=Decimal("100"), hard_cap=Decimal("1000"),
        max_state=AutonomyState.SUPERVISED,
    )},
    thresholds=GraduationThresholds(
        pass_rate={AutonomyState.SUPERVISED: 1.0, AutonomyState.AUTONOMOUS: 1.0},
        adversarial_pass_rate={AutonomyState.SUPERVISED: 0.0, AutonomyState.AUTONOMOUS: 0.9},
        min_samples={AutonomyState.SUPERVISED: 5, AutonomyState.AUTONOMOUS: 1000},
    ),
)
evidence = InMemoryApprovalHistory()
trust = TrustLayer(policy, audit=my_audit_sink,
                   signals=[ApprovalHistorySignal(evidence, window=10)])
gate = WarrantdGate(trust, policy=policy, evidence=evidence,
                    bindings={"issue_refund": ToolBinding(value_param="amount")})

agent = gate.guard_agent(Agent(name="billing", tools=[issue_refund]))

result = await Runner.run(agent, "refund invoice INV-1 by $50")
if result.interruptions:                      # REQUIRE_APPROVAL: run paused
    state = result.to_state()
    for item in result.interruptions:
        print(gate.context_for(item).sentence())
        # -> "this class is 4/10 approvals from SUPERVISED — your decision
        #     feeds its trust record"
        gate.approve(state, item, approver="alice")   # or gate.reject(...)
    result = await Runner.run(agent, state)

After enough clean approvals the same call stops interrupting — it auto-runs within auto_cap. A call above hard_cap never interrupts either: it is blocked outright, with the reason returned as tool output so the model can adapt. Ceilings never move.

Call gate.approve()/gate.reject(), not state.approve() directly — the SDK has no approval callback, so the gate is the hook that turns the human's decision into trust evidence. Bypass it and nothing is learned.

What this adapter does NOT do

  • No decision logic. Every verdict comes from warrantd-core's TrustLayer; this package only translates SDK events. (Verify it: GraduationEngine appears only in the display-only progress helper, and no Decision/Verdict is ever constructed here.)
  • No approval UI. Your interruption handler is the UI; context_for() gives you the graduation sentence to render.
  • No MCP gating. For gating MCP servers with zero agent changes, use warrantd-gateway.
  • No persistence by default. InMemoryApprovalHistory resets on restart. For hash-chained, restart-proof evidence:
pip install "warrantd-openai-agents[gateway]"
from warrantd_openai_agents.stores import sqlite_store
evidence = sqlite_store(".warrantd/evidence.db")   # also usable as audit=

That store is the gateway's chained audit log: warrantd verify-audit checks it and warrantd dashboard displays it read-only.

Learn more

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

warrantd_openai_agents-0.1.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

warrantd_openai_agents-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file warrantd_openai_agents-0.1.0.tar.gz.

File metadata

  • Download URL: warrantd_openai_agents-0.1.0.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for warrantd_openai_agents-0.1.0.tar.gz
Algorithm Hash digest
SHA256 537a4920d5ff5fda5e201c782cc78b3e9f3853ebddb01382c93c65482ec2b1eb
MD5 f09ef2e4c0ba000772abf577714387c2
BLAKE2b-256 5582649a99cec80c11a5ef54aaaf41b74dc0be653cd27130cf525d1f5bf51541

See more details on using hashes here.

Provenance

The following attestation bundles were made for warrantd_openai_agents-0.1.0.tar.gz:

Publisher: release.yml on moritzkazooba-wq/warrantd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file warrantd_openai_agents-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for warrantd_openai_agents-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a70cd5f12ed9d02e7ea06d5a14958eadf6f21c0ba141a415d3e9de501a97145
MD5 d67003c803a621a052dbdafd0a205cb2
BLAKE2b-256 ab32f61e3fca9e60a58bd1cccfad26fab63f4a902f66f945361d0508d1809353

See more details on using hashes here.

Provenance

The following attestation bundles were made for warrantd_openai_agents-0.1.0-py3-none-any.whl:

Publisher: release.yml on moritzkazooba-wq/warrantd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page