From fee8c891e003e252a329ad27f664947c9e71b5ac Mon Sep 17 00:00:00 2001 From: markstuart-oai <323302876+markstuart-oai@users.noreply.github.com> Date: Tue, 10 Nov 2026 06:14:40 +0000 Subject: [PATCH] feat(api): add typed async function tools Castiron-Internal-PR: https://github.com/openai/openai-python-internal/pull/419 Castiron-Source-SHA: 8a6c70ae62ea9b3cdb17177cdb0939a71a382b88 Castiron-Public-Base-SHA: 13c000d1f32c1e3e3c4b3e16bc6b956dfd4f5216 --- .castiron.stats.yml | 10 +++++----- api_reference/openapi.transformed.yml | 14 ++++++++++++++ scripts/castiron/generated-files.json | 14 +++++++------- src/openai/types/beta/agent_tool.py | 5 +++++ src/openai/types/beta/agent_tool_param.py | 10 +++++++++- src/openai/types/beta/persisted_agent_tool.py | 5 +++++ .../types/beta/persisted_agent_tool_param.py | 10 +++++++++- .../api_resources/beta/agents/test_automations.py | 2 ++ tests/api_resources/beta/agents/test_sessions.py | 6 ++++++ tests/api_resources/beta/test_agents.py | 4 ++++ 10 files changed, 66 insertions(+), 14 deletions(-) diff --git a/.castiron.stats.yml b/.castiron.stats.yml index ccff8f2667..d418304f20 100644 --- a/.castiron.stats.yml +++ b/.castiron.stats.yml @@ -1,7 +1,7 @@ schema_version: 1 -generation_id: a3bf0f9e-b174-47ac-a9b6-9e0470a93dad -openapi_spec_hash: 7c533705ce2105493f542be5c5e6eab3 -openapi_transformed_spec_hash: a5880780f650c428cc4897bab03e6da1 +generation_id: a358570b-482e-447e-998d-4f5425c5d316 +openapi_spec_hash: 632d949bd61b801d58c87dcda5ddc605 +openapi_transformed_spec_hash: 9a761f59f8f8e5095ea94652ff2f91d6 config_hash: 01f2d28b82141ac460c9d9e8cc45ee74 -codegen_sha: fa7699eaec8e1f35bda13cf958ad67e7a2b8c168 -codegen_hash: 8c7ec3da81d1769c4ad4c0631e08e93bf5259a96ed6a727a19dd34ba7323880d +codegen_sha: 3a7ad42a6b1bb5cac701b1d6621307e5fadd0b3f +codegen_hash: 908930605be8cf176da37b24e4f5ab6d063001b3d7eb8467e5d1c6a0b2b2b208 diff --git a/api_reference/openapi.transformed.yml b/api_reference/openapi.transformed.yml index 314cdf2151..897b134508 100644 --- a/api_reference/openapi.transformed.yml +++ b/api_reference/openapi.transformed.yml @@ -87149,6 +87149,9 @@ components: defer_loading: type: boolean description: Whether the function is deferred and discovered through tool search. + async: + type: boolean + description: Whether the agent continues without waiting for the function result. required: - type - name @@ -88565,6 +88568,10 @@ components: type: boolean default: false description: Whether this function is deferred and discovered through tool search. Defaults to `false`. + async: + type: boolean + default: false + description: Whether the agent continues without waiting for the function result. Defaults to `false`. required: - type - name @@ -92106,6 +92113,9 @@ components: defer_loading: type: boolean description: Whether the function is deferred and discovered through tool search. + async: + type: boolean + description: Whether the agent continues without waiting for the function result. required: - type - name @@ -92560,6 +92570,10 @@ components: type: boolean default: false description: Whether this function is deferred and discovered through tool search. Defaults to `false`. + async: + type: boolean + default: false + description: Whether the agent continues without waiting for the function result. Defaults to `false`. required: - type - name diff --git a/scripts/castiron/generated-files.json b/scripts/castiron/generated-files.json index d55e4c5048..0ad6364b08 100644 --- a/scripts/castiron/generated-files.json +++ b/scripts/castiron/generated-files.json @@ -1951,11 +1951,11 @@ }, "src/openai/types/beta/agent_tool.py": { "mode": "100644", - "sha256": "ed568481e6de6956b9deccfbb7cce718bba3cfbab6270851602886141af5230c" + "sha256": "145a8f0a9e15d6aa46b116296c9cfbdfd3fc7f5530d99fdb070b3f43439a39b5" }, "src/openai/types/beta/agent_tool_param.py": { "mode": "100644", - "sha256": "50116fba12372f68fc831149fafc3896e5b0be3f8f12bc72cc539ead14be34b3" + "sha256": "44b83c04613add6637b8de7bb48cbf4b1220ddde3d1a2e50e1edfb9d6d4b8990" }, "src/openai/types/beta/agent_update_params.py": { "mode": "100644", @@ -3479,11 +3479,11 @@ }, "src/openai/types/beta/persisted_agent_tool.py": { "mode": "100644", - "sha256": "337c62e5505ccc43656dad66d619b0a0be532181c8f598e7ccf047b9e6ed8824" + "sha256": "b44af4c00085918e647a899f0d6f3efad4b70d59ec7d3034e6130c4128b9374c" }, "src/openai/types/beta/persisted_agent_tool_param.py": { "mode": "100644", - "sha256": "d9e83ab1f8347f4acc525746b1e2c0bc42cbcf64742976dea0983cc419e8fe74" + "sha256": "11cd9c21954b53b21883fb68c5f751811663ee653bfef429c53a81a24916b934" }, "src/openai/types/beta/persisted_mcp_transport.py": { "mode": "100644", @@ -7799,7 +7799,7 @@ }, "tests/api_resources/beta/agents/test_automations.py": { "mode": "100644", - "sha256": "34501f413c83a2ccd9aa494eb59f5c0ae1ba21fa14619dd2bc41571ad8a6422a" + "sha256": "2b10ce0346ce9ff87a52782763f6e544c6a7320a0075c7972624dcc4e8b9cf78" }, "tests/api_resources/beta/agents/test_environments.py": { "mode": "100644", @@ -7807,7 +7807,7 @@ }, "tests/api_resources/beta/agents/test_sessions.py": { "mode": "100644", - "sha256": "fa6f36b530895301c9bb4fe928639dfa4c4f15826f9f5a2f652b0e89ff9a956f" + "sha256": "eda3b15034c7e46e8fe0c4428143b35abd4aed76db58ff0d374625369591ad66" }, "tests/api_resources/beta/agents/test_vaults.py": { "mode": "100644", @@ -7847,7 +7847,7 @@ }, "tests/api_resources/beta/test_agents.py": { "mode": "100644", - "sha256": "6216ae37c6ea996da62e4916570840ed549aeb86603b607d61078b4b30c87d15" + "sha256": "3147acf9a9f9628c4aaed1d51aee13cde66c88bea3e9324d3c157daa68070f68" }, "tests/api_resources/beta/test_assistants.py": { "mode": "100644", diff --git a/src/openai/types/beta/agent_tool.py b/src/openai/types/beta/agent_tool.py index 6588ac8c8a..83cc9f2907 100644 --- a/src/openai/types/beta/agent_tool.py +++ b/src/openai/types/beta/agent_tool.py @@ -3,6 +3,8 @@ from typing import Dict, List, Union, Optional from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from ..._utils import PropertyInfo from ..._models import BaseModel from .mcp_transport import McpTransport @@ -37,6 +39,9 @@ class AgentToolResourceFunction(BaseModel): type: Literal["function"] """The type of the object. Always `function`.""" + async_: Optional[bool] = FieldInfo(alias="async", default=None) + """Whether the agent continues without waiting for the function result.""" + class AgentToolResourceProgrammaticToolCalling(BaseModel): """Enables calling tools from model-generated code.""" diff --git a/src/openai/types/beta/agent_tool_param.py b/src/openai/types/beta/agent_tool_param.py index e8fb85c647..6a80df5020 100644 --- a/src/openai/types/beta/agent_tool_param.py +++ b/src/openai/types/beta/agent_tool_param.py @@ -20,8 +20,16 @@ "AgentToolConfigParamAutomations", ] +_AgentToolConfigParamFunctionReservedKeywords = TypedDict( + "_AgentToolConfigParamFunctionReservedKeywords", + { + "async": bool, + }, + total=False, +) -class AgentToolConfigParamFunction(TypedDict, total=False): + +class AgentToolConfigParamFunction(_AgentToolConfigParamFunctionReservedKeywords, total=False): """A function defined by the application.""" description: Required[str] diff --git a/src/openai/types/beta/persisted_agent_tool.py b/src/openai/types/beta/persisted_agent_tool.py index 136ee6a24f..f84d002362 100644 --- a/src/openai/types/beta/persisted_agent_tool.py +++ b/src/openai/types/beta/persisted_agent_tool.py @@ -3,6 +3,8 @@ from typing import Dict, List, Union, Optional from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from ..._utils import PropertyInfo from ..._models import BaseModel from .persisted_mcp_transport import PersistedMcpTransport @@ -38,6 +40,9 @@ class PersistedAgentToolResourceFunction(BaseModel): type: Literal["function"] """The type of the object. Always `function`.""" + async_: Optional[bool] = FieldInfo(alias="async", default=None) + """Whether the agent continues without waiting for the function result.""" + class PersistedAgentToolResourceToolSearch(BaseModel): """Discovers deferred function tools and loads them into the model context.""" diff --git a/src/openai/types/beta/persisted_agent_tool_param.py b/src/openai/types/beta/persisted_agent_tool_param.py index 2e49b46e4f..c0ac64fc42 100644 --- a/src/openai/types/beta/persisted_agent_tool_param.py +++ b/src/openai/types/beta/persisted_agent_tool_param.py @@ -20,8 +20,16 @@ "PersistedAgentToolConfigParamAutomations", ] +_PersistedAgentToolConfigParamFunctionReservedKeywords = TypedDict( + "_PersistedAgentToolConfigParamFunctionReservedKeywords", + { + "async": bool, + }, + total=False, +) -class PersistedAgentToolConfigParamFunction(TypedDict, total=False): + +class PersistedAgentToolConfigParamFunction(_PersistedAgentToolConfigParamFunctionReservedKeywords, total=False): """A function defined by the application.""" description: Required[str] diff --git a/tests/api_resources/beta/agents/test_automations.py b/tests/api_resources/beta/agents/test_automations.py index 667ecde60b..823ff0b7c7 100644 --- a/tests/api_resources/beta/agents/test_automations.py +++ b/tests/api_resources/beta/agents/test_automations.py @@ -331,6 +331,7 @@ def test_method_update_with_all_params(self, client: OpenAI) -> None: "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ], @@ -839,6 +840,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ], diff --git a/tests/api_resources/beta/agents/test_sessions.py b/tests/api_resources/beta/agents/test_sessions.py index 422baacf64..1a1dcb0f01 100644 --- a/tests/api_resources/beta/agents/test_sessions.py +++ b/tests/api_resources/beta/agents/test_sessions.py @@ -53,6 +53,7 @@ def test_method_create_with_all_params_overload_1(self, client: OpenAI) -> None: "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ], @@ -129,6 +130,7 @@ def test_method_create_with_all_params_overload_2(self, client: OpenAI) -> None: "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ], @@ -229,6 +231,7 @@ def test_method_update_with_all_params(self, client: OpenAI) -> None: "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ], @@ -385,6 +388,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ], @@ -461,6 +465,7 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ], @@ -561,6 +566,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ], diff --git a/tests/api_resources/beta/test_agents.py b/tests/api_resources/beta/test_agents.py index 7cd7acdcdf..80a121cc00 100644 --- a/tests/api_resources/beta/test_agents.py +++ b/tests/api_resources/beta/test_agents.py @@ -56,6 +56,7 @@ def test_method_create_with_all_params(self, client: OpenAI) -> None: "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ], @@ -160,6 +161,7 @@ def test_method_update_with_all_params(self, client: OpenAI) -> None: "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ], @@ -310,6 +312,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ], @@ -414,6 +417,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> "name": "name", "parameters": {"foo": "bar"}, "type": "function", + "async": True, "defer_loading": True, } ],