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

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata


class AgentMetricsResponse(UniversalBaseModel):
    """
    Aggregated metrics for an agent.
    """

    avg_task_duration_seconds: typing.Optional[float] = pydantic.Field(default=None)
    """
    Average duration of completed/failed tasks in seconds. None if no tasks have finished in the time window.
    """

    error_log_count24h: typing_extensions.Annotated[int, FieldMetadata(alias="error_log_count_24h")] = pydantic.Field(
        alias="error_log_count_24h"
    )
    """
    Number of ERROR/CRITICAL level logs in the last 24 hours
    """

    task_count24h: typing_extensions.Annotated[int, FieldMetadata(alias="task_count_24h")] = pydantic.Field(
        alias="task_count_24h"
    )
    """
    Total number of tasks created in the last 24 hours
    """

    task_success_rate_pct: typing.Optional[float] = pydantic.Field(default=None)
    """
    Percentage of successful tasks (COMPLETED) vs failed tasks. None if no tasks have finished in the time window.
    """

    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
