Skip to content
96 changes: 4 additions & 92 deletions src/openai/types/beta/beta_response_steer_input_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,117 +2,29 @@

from __future__ import annotations

from typing import Union, Iterable, Optional
from typing import Union, Iterable
from typing_extensions import Literal, Required, TypeAlias, TypedDict

from .beta_response_steer_input_content_param import BetaResponseSteerInputContentParam
from .beta_response_function_call_output_item_list_param import BetaResponseFunctionCallOutputItemListParam

__all__ = [
"BetaResponseSteerInputParam",
"ResponseSteerInputItemList",
"ResponseSteerInputItemListMessage",
"ResponseSteerInputItemListMessageAgent",
"ResponseSteerInputItemListFunctionCallOutput",
"ResponseSteerInputItemListFunctionCallOutputAgent",
"ResponseSteerInputItemListFunctionCallOutputCaller",
"ResponseSteerInputItemListFunctionCallOutputCallerDirect",
"ResponseSteerInputItemListFunctionCallOutputCallerProgram",
]


class ResponseSteerInputItemListMessageAgent(TypedDict, total=False):
"""The agent that produced this item."""

agent_name: Required[str]
"""The canonical name of the agent that produced this item."""


class ResponseSteerInputItemListMessage(TypedDict, total=False):
content: Required[Union[Iterable[BetaResponseSteerInputContentParam], str]]
"""The message content, as an array of content parts."""

role: Required[Literal["user"]]
"""The message role. Always `user`."""

type: Required[Literal["message"]]
"""The item type. Always `message`."""

id: Optional[str]
"""The unique ID of this message item."""

agent: Optional[ResponseSteerInputItemListMessageAgent]
"""The agent that produced this item."""

status: Optional[str]
"""The status of the message item."""


class ResponseSteerInputItemListFunctionCallOutputAgent(TypedDict, total=False):
"""The agent that produced this item."""
type: Literal["message"]
"""The optional item type. When provided, always `message`."""

agent_name: Required[str]
"""The canonical name of the agent that produced this item."""


class ResponseSteerInputItemListFunctionCallOutputCallerDirect(TypedDict, total=False):
type: Required[Literal["direct"]]
"""The caller type. Always `direct`."""


class ResponseSteerInputItemListFunctionCallOutputCallerProgram(TypedDict, total=False):
caller_id: Required[str]
"""The call ID of the program item that produced this tool call."""

type: Required[Literal["program"]]
"""The caller type. Always `program`."""


ResponseSteerInputItemListFunctionCallOutputCaller: TypeAlias = Union[
ResponseSteerInputItemListFunctionCallOutputCallerDirect, ResponseSteerInputItemListFunctionCallOutputCallerProgram
]


class ResponseSteerInputItemListFunctionCallOutput(TypedDict, total=False):
"""The output of a function tool call."""

output: Required[Union[str, BetaResponseFunctionCallOutputItemListParam]]
"""Text, image, or file output of the function tool call."""

type: Required[Literal["function_call_output"]]
"""The type of the function tool call output. Always `function_call_output`."""

id: Optional[str]
"""The unique ID of the function tool call output.

Populated when this item is returned via API.
"""

agent: Optional[ResponseSteerInputItemListFunctionCallOutputAgent]
"""The agent that produced this item."""

call_id: Optional[str]
"""The unique ID of the function tool call generated by the model."""

caller: Optional[ResponseSteerInputItemListFunctionCallOutputCaller]
"""The execution context that produced this tool call."""

name: Optional[str]
"""The name of the tool that produced the output."""

namespace: Optional[str]
"""The namespace of the tool that produced the output."""

status: Optional[Literal["in_progress", "completed", "incomplete"]]
"""The status of the item.

One of `in_progress`, `completed`, or `incomplete`. Populated when items are
returned via API.
"""


ResponseSteerInputItemList: TypeAlias = Union[
ResponseSteerInputItemListMessage, ResponseSteerInputItemListFunctionCallOutput
]
ResponseSteerInputItemList: TypeAlias = ResponseSteerInputItemListMessage

BetaResponseSteerInputParam: TypeAlias = Union[str, Iterable[ResponseSteerInputItemList]]
74 changes: 4 additions & 70 deletions src/openai/types/responses/response_steer_input_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@

from __future__ import annotations

from typing import Union, Iterable, Optional
from typing import Union, Iterable
from typing_extensions import Literal, Required, TypeAlias, TypedDict

from .response_steer_input_content_param import ResponseSteerInputContentParam
from .response_function_call_output_item_list_param import ResponseFunctionCallOutputItemListParam

__all__ = [
"ResponseSteerInputParam",
"ResponseSteerInputItemList",
"ResponseSteerInputItemListMessage",
"ResponseSteerInputItemListFunctionCallOutput",
"ResponseSteerInputItemListFunctionCallOutputCaller",
"ResponseSteerInputItemListFunctionCallOutputCallerDirect",
"ResponseSteerInputItemListFunctionCallOutputCallerProgram",
]


Expand All @@ -26,71 +21,10 @@ class ResponseSteerInputItemListMessage(TypedDict, total=False):
role: Required[Literal["user"]]
"""The message role. Always `user`."""

type: Required[Literal["message"]]
"""The item type. Always `message`."""
type: Literal["message"]
"""The optional item type. When provided, always `message`."""

id: Optional[str]
"""The unique ID of this message item."""

status: Optional[str]
"""The status of the message item."""


class ResponseSteerInputItemListFunctionCallOutputCallerDirect(TypedDict, total=False):
type: Required[Literal["direct"]]
"""The caller type. Always `direct`."""


class ResponseSteerInputItemListFunctionCallOutputCallerProgram(TypedDict, total=False):
caller_id: Required[str]
"""The call ID of the program item that produced this tool call."""

type: Required[Literal["program"]]
"""The caller type. Always `program`."""


ResponseSteerInputItemListFunctionCallOutputCaller: TypeAlias = Union[
ResponseSteerInputItemListFunctionCallOutputCallerDirect, ResponseSteerInputItemListFunctionCallOutputCallerProgram
]


class ResponseSteerInputItemListFunctionCallOutput(TypedDict, total=False):
"""The output of a function tool call."""

output: Required[Union[str, ResponseFunctionCallOutputItemListParam]]
"""Text, image, or file output of the function tool call."""

type: Required[Literal["function_call_output"]]
"""The type of the function tool call output. Always `function_call_output`."""

id: Optional[str]
"""The unique ID of the function tool call output.

Populated when this item is returned via API.
"""

call_id: Optional[str]
"""The unique ID of the function tool call generated by the model."""

caller: Optional[ResponseSteerInputItemListFunctionCallOutputCaller]
"""The execution context that produced this tool call."""

name: Optional[str]
"""The name of the tool that produced the output."""

namespace: Optional[str]
"""The namespace of the tool that produced the output."""

status: Optional[Literal["in_progress", "completed", "incomplete"]]
"""The status of the item.

One of `in_progress`, `completed`, or `incomplete`. Populated when items are
returned via API.
"""


ResponseSteerInputItemList: TypeAlias = Union[
ResponseSteerInputItemListMessage, ResponseSteerInputItemListFunctionCallOutput
]
ResponseSteerInputItemList: TypeAlias = ResponseSteerInputItemListMessage

ResponseSteerInputParam: TypeAlias = Union[str, Iterable[ResponseSteerInputItemList]]
20 changes: 20 additions & 0 deletions tests/test_response_steer_input_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from openai.types.beta import beta_response_steer_input_param as beta_steer_param
from openai.types.responses import response_steer_input_param as steer_param


def test_stable_steer_params_match_wire_contract() -> None:
message = steer_param.ResponseSteerInputItemListMessage

assert set(message.__annotations__) == {"content", "role", "type"}
assert set(message.__required_keys__) == {"content", "role"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid checking required keys under postponed annotations

Because both parameter modules enable from __future__ import annotations, Required[...] is stored as a forward reference when the TypedDict class is created, so message.__required_keys__ is empty rather than {"content", "role"}. This assertion—and the equivalent beta assertion—therefore fails on every supported Python version; verify requiredness through resolved type hints instead.

Useful? React with 👍 / 👎.

assert steer_param.ResponseSteerInputItemList is message
assert "ResponseSteerInputItemListFunctionCallOutput" not in steer_param.__all__


def test_beta_steer_params_match_wire_contract() -> None:
message = beta_steer_param.ResponseSteerInputItemListMessage

assert set(message.__annotations__) == {"content", "role", "type"}
assert set(message.__required_keys__) == {"content", "role"}
assert beta_steer_param.ResponseSteerInputItemList is message
assert "ResponseSteerInputItemListFunctionCallOutput" not in beta_steer_param.__all__