Skip to main content

OpenAI Agents SDK integration for LatchGate — execution security kernel for AI agents

Project description

latchgate-openai-agents

OpenAI Agents SDK integration for LatchGate — execution security kernel for AI agents.

Every tool call goes through LatchGate's enforcement pipeline: auth => policy => WASM sandbox => verification => signed receipt. The LLM never holds credentials and never contacts external systems directly.

Installation

pip install latchgate-openai-agents

Requires a running LatchGate instance:

curl -fsSL https://raw.githubusercontent.com/latchgate-ai/latchgate/main/install.sh | bash && latchgate up

Quick start

from agents import Agent, Runner
from latchgate_openai_agents import latchgate_tools

async def main():
    tools = await latchgate_tools(gate_url="http://localhost:3000")

    agent = Agent(
        name="Secure Worker",
        instructions="You have access to LatchGate-protected tools with full audit trail.",
        tools=tools,
    )

    result = await Runner.run(agent, "Fetch https://httpbin.org/get")
    print(result.final_output)

API

latchgate_tools(**kwargs)

Async factory — discovers actions and returns FunctionTool instances:

tools = await latchgate_tools(
    gate_url="http://localhost:3000",    # Required (or set LATCHGATE_URL)
    agent_id="my-agent",                 # Default: "openai-agents"
    include={"http_fetch", "database"},  # Optional
    exclude={"send_message"},            # Optional
    on_audit=my_audit_callback,          # Optional: receipt callback
)

agent = Agent(name="Worker", tools=tools)

latchgate_tools_from_descriptors(descriptors, *, client)

Create tools from pre-fetched descriptors (no network):

from latchgate_openai_agents import latchgate_tools_from_descriptors, ActionDescriptor

create_tool(descriptor, client)

Create a single FunctionTool from an ActionDescriptor:

from latchgate_openai_agents import create_tool

Error handling

LatchGate errors are returned as structured strings (not raised):

LatchGate error Tool returns
Policy denied "ERROR: Action '...' denied: {reason}..."
Approval required "ERROR: ... requires human approval..." (approval_id emitted via log, not to the model)
Budget exhausted "ERROR: Budget exhausted..."
Invalid JSON input "ERROR: Invalid JSON input..."
Transport / infra "ERROR: LatchGate error..."

Output format

Tool output is a JSON string containing only the action result. Enforcement metadata (receipt ID, trace ID, verification) is never returned to the model — it is emitted at INFO log level and via the optional on_audit callback.

{"status": 200, "body": "{...}"}

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

latchgate_openai_agents-0.1.1.tar.gz (88.5 kB view details)

Uploaded Source

Built Distribution

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

latchgate_openai_agents-0.1.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file latchgate_openai_agents-0.1.1.tar.gz.

File metadata

  • Download URL: latchgate_openai_agents-0.1.1.tar.gz
  • Upload date:
  • Size: 88.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for latchgate_openai_agents-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6ba9380ead7d668f00f9fec6cbc4ede6cb083eb26936068b05de1bf5abbcce15
MD5 231238fb7396bc5e61e2d2746b375597
BLAKE2b-256 7c047993b950d4f3ffe61f019a44625e70eaac5c678be794eed5672b44e793bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for latchgate_openai_agents-0.1.1.tar.gz:

Publisher: release.yml on latchgate-ai/latchgate-integrations

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

File details

Details for the file latchgate_openai_agents-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for latchgate_openai_agents-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1d24809c62b36798833ab57bbed5408883fc8d053a66dc5fcb59dcdcc1a616a
MD5 2a7efb76901c643556749d00851f38ff
BLAKE2b-256 6f44f10ba8660669dd539458ec3d4f8cfe06326d0438cff5675ffd26b1e438b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for latchgate_openai_agents-0.1.1-py3-none-any.whl:

Publisher: release.yml on latchgate-ai/latchgate-integrations

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