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

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

from ...._utils import PropertyInfo
from ...._models import BaseModel
from .beta_managed_agents_text_block import BetaManagedAgentsTextBlock
from .beta_managed_agents_image_block import BetaManagedAgentsImageBlock
from .beta_managed_agents_document_block import BetaManagedAgentsDocumentBlock
from .beta_managed_agents_search_result_block import BetaManagedAgentsSearchResultBlock

__all__ = ["BetaManagedAgentsAgentToolResultEvent", "Content"]

Content: TypeAlias = Annotated[
    Union[
        BetaManagedAgentsTextBlock,
        BetaManagedAgentsImageBlock,
        BetaManagedAgentsDocumentBlock,
        BetaManagedAgentsSearchResultBlock,
    ],
    PropertyInfo(discriminator="type"),
]


class BetaManagedAgentsAgentToolResultEvent(BaseModel):
    """Event representing the result of an agent tool execution."""

    id: str
    """Unique identifier for this event."""

    processed_at: datetime
    """A timestamp in RFC 3339 format"""

    tool_use_id: str
    """The id of the `agent.tool_use` event this result corresponds to."""

    type: Literal["agent.tool_result"]

    content: Optional[List[Content]] = None
    """The result content returned by the tool."""

    is_error: Optional[bool] = None
    """Whether the tool execution resulted in an error."""
