# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel


class State(UniversalBaseModel):
    """
    Represents a state in the agent system. A state is associated uniquely with a task and an agent.

    This entity is used to store states in MongoDB, with each state
    associated with a specific task and agent. The combination of task_id and agent_id is globally unique.

    The state is a dictionary of arbitrary data.
    """

    agent_id: str
    created_at: dt.datetime = pydantic.Field()
    """
    The timestamp when the state was created
    """

    id: str = pydantic.Field()
    """
    The task state's unique id
    """

    state: typing.Dict[str, typing.Any]
    task_id: str
    updated_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    The timestamp when the state was last updated
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
