Skip to main content

deny-sh-openai-agents

Wrap a deny.sh vault entry as an OpenAI Agents SDK tool (Python). The credential resolves inside the tool boundary; only a narrowed DTO reaches the model. Fail-closed leak sweep.

pip install deny-sh-openai-agents openai-agents

Usage

import os
import requests
from pydantic import BaseModel
from agents import Agent, Runner
from deny_sh_openai_agents import deny_vault_tool

class InvoiceArgs(BaseModel):
    id: str

def lookup(stripe_key: str, args: dict) -> dict:
    r = requests.get(
        f"https://api.stripe.com/v1/invoices/{args['id']}",
        headers={"Authorization": f"Bearer {stripe_key}"},
    )
    body = r.json()
    # narrowed DTO -- never the raw key, never the raw upstream body
    return {"id": body.get("id"), "amount_due": body.get("amount_due"), "status": body.get("status")}

invoice_tool = deny_vault_tool(
    label="stripe-prod",                  # or: id="item_abc"
    password=os.environ["VAULT_PW"],      # server env, never the prompt
    name="get_invoice",
    description="Look up a Stripe invoice by id",
    args_schema=InvoiceArgs,
    use=lookup,
)

agent = Agent(
    name="Billing",
    instructions="Help the user with their invoices.",
    tools=[invoice_tool],
)

result = Runner.run_sync(agent, "What is the status of invoice in_1?")
print(result.final_output)

The Stripe key is resolved + consumed entirely inside lookup. The agent and the model provider see only the input args and the narrowed return. The key never enters the model's context window. If use ever returns the raw secret, the leak sweep raises (DenyLeakError) and the secret never crosses back into the model context.

Multi-tenant

Pass a per-tenant client_options={"api_key": ...} and password. One tenant cannot decrypt another's vault entry; the boundary is cryptographic, not policy-based.

Config

Field Required Notes
label / id one of vault entry label, or a stable item id
password yes vault wrap password
name, description, args_schema yes standard Agents SDK tool fields (args_schema is a pydantic model)
use(secret, args) yes privileged work; return a narrowed DTO
client_options no forwarded to deny_sh.vault_get (api_key, base_url, ...)
leak_sweep no default True; fail-closed scan of the returned DTO

Apache-2.0. Part of deny-sh-integrations.

Metadata

Release files for deny-sh-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)

Source distribution for deny-sh-openai-agents 0.1.0
File Size Uploaded
deny_sh_openai_agents-0.1.0.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for deny-sh-openai-agents 0.1.0
File Interpreter ABI Platform
deny_sh_openai_agents-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.4 kB

Release files / deny_sh_openai_agents-0.1.0.tar.gz

Download URL deny_sh_openai_agents-0.1.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3cf65492abebc1216ce4b1b17e377408316a53b58193fdc30a1bd5d6df7684af
BLAKE2b-256 checksum
How to use checksums
027bf8a00c4d002d95124c32e78e105a2acf27ef3ddfa47a078b26d3f6de35bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / deny_sh_openai_agents-0.1.0-py3-none-any.whl

Download URL deny_sh_openai_agents-0.1.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3aa78e4b94df535851be9c90c7addea5e5be59632ee475c4c067e3d1f7f08b33
BLAKE2b-256 checksum
How to use checksums
0e7ff49dbf57614d6afd589dad9dc28f44e165e6cf8fe094f622d4f7a9806023
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page