# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Union, Optional
from typing_extensions import Literal, Annotated, TypeAlias

from ..._utils import PropertyInfo
from ..._models import BaseModel

__all__ = ["BetaResponseCustomToolCall", "Agent", "Caller", "CallerDirect", "CallerProgram"]


class Agent(BaseModel):
    """The agent that produced this item."""

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


class CallerDirect(BaseModel):
    type: Literal["direct"]


class CallerProgram(BaseModel):
    caller_id: str
    """The call ID of the program item that produced this tool call."""

    type: Literal["program"]


Caller: TypeAlias = Annotated[Union[CallerDirect, CallerProgram, None], PropertyInfo(discriminator="type")]


class BetaResponseCustomToolCall(BaseModel):
    """A call to a custom tool created by the model."""

    call_id: str
    """An identifier used to map this custom tool call to a tool call output."""

    input: str
    """The input for the custom tool call generated by the model."""

    name: str
    """The name of the custom tool being called."""

    type: Literal["custom_tool_call"]
    """The type of the custom tool call. Always `custom_tool_call`."""

    id: Optional[str] = None
    """The unique ID of the custom tool call in the OpenAI platform."""

    agent: Optional[Agent] = None
    """The agent that produced this item."""

    caller: Optional[Caller] = None
    """The execution context that produced this tool call."""

    namespace: Optional[str] = None
    """The namespace of the custom tool being called."""
