Skip to content

keelgate.adapters.openai_agents

Stability of each symbol (stable or provisional) is listed in the API contract. Narrative and semantics are in the integration contract.

OpenAI Agents SDK adapter: governed function tools, and an LLMClient-backed model.

Needs keelgate[openai]. Note that the SDK itself requires a recent Python 3.11 patch release or newer: 3.11.0 has a typing bug that stops import agents from working at all.

KeelgateModel

Bases: Model

An Agents SDK Model whose completions come from a Keelgate LLMClient.

governed_function_tools

governed_function_tools(
    toolset: GovernedToolset,
) -> list[FunctionTool]

One FunctionTool per governed tool. Each invocation goes through the gateway.

The SDK's own approval and guardrail features are left alone and are not relied on: authorisation is decided by the gateway, whatever the SDK is configured to do.

to_keelgate_messages

to_keelgate_messages(
    system_instructions: str | None,
    items: str | Sequence[Any],
) -> tuple[Message, ...]

Convert Agents SDK input items into Keelgate Message objects.