Skip to main content

AgentLock authorization middleware for the OpenAI Agents SDK.

Project description

openai-agentlock

AgentLock authorization middleware for the OpenAI Agents SDK.

Wraps FunctionTool instances so every tool call passes through an AuthorizationGate before the tool body runs. Denials are returned to the model as plain strings; allowed calls receive a single-use execution token, optional output transforms, and provenance tracking.

Install

pip install openai-agentlock

Minimal usage

from agents import Agent, function_tool
from agentlock import AuthorizationGate, AgentLockPermissions
from openai_agentlock import lock_agent

gate = AuthorizationGate()

@function_tool
def read_record(record_id: str) -> str:
    return f"record {record_id}"

agent = Agent(name="demo", tools=[read_record])

lock_agent(
    agent,
    gate,
    permissions={
        "read_record": AgentLockPermissions(
            allowed_roles=["reader"],
            requires_auth=True,
        ),
    },
)

Pass an identity object through RunContextWrapper.context that exposes user_id, role, and (optionally) session_id so the gate can evaluate role and scope.

License

Apache 2.0.

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

openai_agentlock-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

openai_agentlock-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openai_agentlock-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for openai_agentlock-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9037153dd9c65b2b3f89b4cc08a049d8a800c502870087b451d92a3311c2c728
MD5 ba86757fbbbf3a4d5ea0656f79c49f30
BLAKE2b-256 717af8841c2716e8999212ecad991547b331ccf7975d7c7e3f941e8267d930b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openai_agentlock-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8fd6dabc207d6ea011125e52d1fa4182c9ccb3d14122f7d57b2b7ce10b9f3bdf
MD5 f37a8e89808e189f413561d50fce942d
BLAKE2b-256 cdf4ef18652db26e67d0dc617ab98b48fd59e53e222ccccafbbab4bf780330d6

See more details on using hashes here.

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