SIGN IN SIGN UP

feat(beta): expose typed application actions as agent tools (#4006)

## Summary

Expose an application's typed functions as beta Agents tools without
maintaining a separate JSON schema and argument unpacker.

Before:
```python
item_definition = {
    "type": "function", "name": "lookup_item", "description": "Look up a catalog item",
    "parameters": {
        "type": "object", "properties": {"item_id": {"type": "string"}},
        "required": ["item_id"], "additionalProperties": False,
    },
}
handlers = {"lookup_item": lambda args: lookup_item(args["item_id"])}
```

After:
```python
from openai.lib.beta.agents import function_tool

@function_tool(name="lookup_item")
def lookup(item_id: str) -> dict[str, str]:
    """Look up a catalog item."""
    return catalog.lookup(item_id)

# At session creation: agent={"model": MODEL, "tools": [lookup.definition]}
with client.beta.agents.sessions.stream(
    SESSION_ID, input="Find catalog item A123.",
    tool_handlers={lookup.name: lookup},
) as stream:
    stream.until_done()
```

The beta helper validates arguments with Pydantic before calling the
application. Dependencies stay in ordinary closures or bound methods;
async callbacks use `AsyncOpenAI`. Both flows reuse the existing
dispatcher and its result submission behavior.
A
Alex Chang committed
f219c5581661408688195659ab0137927ba9a033
Parent: 157ac4c
Committed by GitHub <noreply@github.com> on 10/1/2026, 2:21:29 PM