Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(aio): enforce one report config per evaluation (#69020)

Radu Raicea7924750b7de2
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index eb2752fffba7..d2842f774b81 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6041,7 +6041,7 @@ snapshots:
scenes-app-insights-trendsslopegraph--trends-slope-graph--dark:
hash: v1.k794b7964.7b6bb33aaba2c334ded0898f97b7e316248e1639144c49e2039c880a16672ce3.RFWxmLTjalbL8Nszbl4hySEvS8xYi28uZJp2_E9EtxQ
scenes-app-insights-trendsslopegraph--trends-slope-graph--light:
- hash: v1.k794b7964.435ec6cacedc635d128f46c84567002eae11aa76758c130c39ff877197a75542.B6jsuSizg7bPm8wDE8N62O1k-C5CPomtRNXHXkSzwK8
+ hash: v1.k794b7964.4e8dfdda6a2ff4ec36b24b1498e150b34d935ed34006feb0bedd0d1865b0b029.HqV7Rdk_En7fs9BFZSGFnqCDP27_jjZlJ8SNQYRtT0A
scenes-app-insights-trendsslopegraph--trends-slope-graph-edit--dark:
hash: v1.k794b7964.a79e9f9b09872c1379566cac070987db5158b3f47129fe653ff1a4ec94e51ce5.WmkWzqWIPX_nHjS0tiGL8wPflEpxIM0itFt1G_ULgFM
scenes-app-insights-trendsslopegraph--trends-slope-graph-edit--light:
@@ -6179,13 +6179,13 @@ snapshots:
scenes-app-links--new-link--light:
hash: v1.k794b7964.96b374104c35e53400745ac6a24686d195f42222e24d097dd1363983e6f43e8c.t4_adK3iuY98o2Ro0cnQGdfudgzw5wRasCqIsMs2wUc
scenes-app-llm-observability-evaluationreportconfig--lemon-ui--dark:
- hash: v1.k794b7964.d098d0593f4dcc1434c6ceb0ddc616a49ba77a2b1ab1027f767d1efb3e7c1daf.MSc4t2mQZUSIaBoyMSA3MqSuytgJIzBbVB62APeyzLA
+ hash: v1.k794b7964.195aa4a5a39e8f947e17fe67f5c23303b7dd0579c278907761be24a08780be92.IkGQtAI95T60kJKVZcmmFBIWNCd4meuJv-bcNDoohwU
scenes-app-llm-observability-evaluationreportconfig--lemon-ui--light:
- hash: v1.k794b7964.39b9bf7c583a8d231d422296577755596aa62f04908c8ea5d652a4659ca9d2d9.5sVxYsjB3vETvKskHJk7CFvhOJlL4Bbnfw2mVxnzLT0
+ hash: v1.k794b7964.e6179df07dd55d64e0140d40ac812feb4662e28e5bded7ce2cf9e2575f245626.MyOxoktsQii79iZFaoDLCYAhjrx2QQs-B7SShBLrqL4
scenes-app-llm-observability-evaluationreportconfig--quill--dark:
- hash: v1.k794b7964.a4e3c735555c8bcfae469422c0428b9f6fb665dbeda38f973f2ac92385b778d3.Oj7rUiqlrnvxl5WmUwvb-Ng1ZOL52_UKyWQEBohvCsQ
+ hash: v1.k794b7964.195aa4a5a39e8f947e17fe67f5c23303b7dd0579c278907761be24a08780be92.t2Zgr2Pj-cL6F6Xx11DpcCyR1L0QQ8fD17WzQNmXbw8
scenes-app-llm-observability-evaluationreportconfig--quill--light:
- hash: v1.k794b7964.3bafcdbe9f413a0f22215f1e2ed4083e39379ad73aefbc2a4312ea62b8d770e4.qEZmCfxl_QJdqebFjmRAgCUV1IcUREkzC_hFkzUF-CI
+ hash: v1.k794b7964.e6179df07dd55d64e0140d40ac812feb4662e28e5bded7ce2cf9e2575f245626.4iGTruUDV858d17xZIUMJCG2xFeWLagkzakPS2Yw4Ps
scenes-app-marketing-analytics-cell-actions--campaign-cell-action-globally-mapped--dark:
hash: v1.k794b7964.52cf1cc9ecc8ac0c8dc3ff23da8f0e0f2605629c3df6ecbb5ed9608f570c4784.NtNmI3-76PkNhp-wrgqn8-92duqzx8Svtopeh0m9xw8
scenes-app-marketing-analytics-cell-actions--campaign-cell-action-globally-mapped--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 770367a76870..c4cdc6c9e4db 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -346,7 +346,6 @@ export const FEATURE_FLAGS = {
LLM_ANALYTICS_CUSTOM_PARSERS: 'ai-observability-custom-parsers', // owner: #team-ai-observability
LLM_ANALYTICS_DATASETS: 'llm-analytics-datasets', // owner: #team-ai-observability #team-posthog-ai
LLM_ANALYTICS_EARLY_ADOPTERS: 'llm-analytics-early-adopters', // owner: #team-ai-observability
- LLM_ANALYTICS_EVALUATIONS_REPORTS: 'llm-analytics-evaluations-reports', // owner: #team-ai-observability
LLM_ANALYTICS_EVALUATIONS_SENTIMENT: 'llm-analytics-sentiment-evaluations', // owner: #team-ai-observability
LLM_ANALYTICS_OFFLINE_EVALS: 'llm-analytics-offline-evals', // owner: #team-ai-observability
LLM_ANALYTICS_TAGS: 'llm-analytics-tags', // owner: #team-ai-observability
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index b38057727b5f..83ce14df9e0e 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -521,6 +521,9 @@ SPECTACULAR_SETTINGS = {
# Disambiguates from the same-valued inline enum on the signals LogsAlertStateChangeSignalExtra contract.
"LogsAlertThresholdOperatorEnum": "products.logs.backend.models.LogsAlertConfiguration.ThresholdOperator",
"LLMProviderEnum": "products.ai_observability.backend.models.provider_keys.LLMProvider",
+ "EvaluationReportFrequencyEnum": (
+ "products.ai_observability.backend.models.evaluation_reports.EvaluationReport.Frequency"
+ ),
"HogFlowStatusEnum": "products.workflows.backend.models.hog_flow.hog_flow.HogFlow.State",
"MCPAuthTypeEnum": "products.mcp_store.backend.models.AUTH_TYPE_CHOICES",
"TaskRunStatusEnum": "products.tasks.backend.models.TaskRun.Status",
diff --git a/products/ai_observability/backend/api/evaluation_reports.py b/products/ai_observability/backend/api/evaluation_reports.py
index 1d3a8f799635..2b7ca69d72c0 100644
--- a/products/ai_observability/backend/api/evaluation_reports.py
+++ b/products/ai_observability/backend/api/evaluation_reports.py
@@ -5,6 +5,7 @@ from typing import Any
from django.conf import settings
from django.db.models import QuerySet
+from django.utils import timezone
import structlog
from asgiref.sync import async_to_sync
@@ -31,6 +32,43 @@ from products.workflows.backend.utils.rrule_utils import validate_rrule
logger = structlog.get_logger(__name__)
+SCHEDULE_RRULE_ERROR = (
+ "Scheduled reports support daily or weekly cadences. Use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'."
+)
+VALID_WEEKDAYS = {"MO", "TU", "WE", "TH", "FR", "SA", "SU"}
+
+
+def default_schedule_anchor() -> dt.datetime:
+ return timezone.now().replace(minute=0, second=0, microsecond=0)
+
+
+class EvaluationReportListQuerySerializer(serializers.Serializer):
+ evaluation = serializers.UUIDField(
+ required=False,
+ help_text="Only return report configs for this evaluation UUID.",
+ )
+
+
+def validate_report_schedule_rrule(rrule_string: str) -> None:
+ parts: dict[str, str] = {}
+ for part in rrule_string.split(";"):
+ if "=" not in part:
+ raise ValueError(SCHEDULE_RRULE_ERROR)
+ key, value = part.split("=", 1)
+ if key in parts:
+ raise ValueError(SCHEDULE_RRULE_ERROR)
+ parts[key] = value
+
+ if parts == {"FREQ": "DAILY"}:
+ return
+
+ if set(parts) == {"FREQ", "BYDAY"} and parts["FREQ"] == "WEEKLY":
+ weekdays = parts["BYDAY"].split(",")
+ if weekdays and all(day in VALID_WEEKDAYS for day in weekdays) and len(weekdays) == len(set(weekdays)):
+ return
+
+ raise ValueError(SCHEDULE_RRULE_ERROR)
+
class EvaluationReportSerializer(serializers.ModelSerializer):
class Meta:
@@ -55,33 +93,40 @@ class EvaluationReportSerializer(serializers.ModelSerializer):
"created_by",
"created_at",
]
- read_only_fields = ["id", "next_delivery_date", "last_delivered_at", "created_by", "created_at"]
+ read_only_fields = [
+ "id",
+ "starts_at",
+ "timezone_name",
+ "next_delivery_date",
+ "deleted",
+ "last_delivered_at",
+ "created_by",
+ "created_at",
+ ]
extra_kwargs = {
"evaluation": {"help_text": "UUID of the evaluation this report config belongs to."},
"frequency": {
"help_text": (
"How report generation is triggered. 'every_n' fires once N new evaluation results have "
"accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence "
- "defined by rrule + starts_at + timezone_name."
+ "defined by rrule."
)
},
"rrule": {
"help_text": (
- "RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the "
- "anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise."
+ "RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are "
+ "supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is "
+ "'scheduled'; ignored otherwise."
)
},
"starts_at": {
"help_text": (
- "Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation "
- "is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise."
+ "Read-only anchor datetime used to expand scheduled reports. The server sets this automatically "
+ "when a report is switched to scheduled mode."
)
},
"timezone_name": {
- "help_text": (
- "IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across "
- "DST transitions (e.g. 'America/New_York'). Defaults to 'UTC'."
- )
+ "help_text": "Read-only timezone used for scheduled reports. Evaluation reports use UTC."
},
"delivery_targets": {
"help_text": (
@@ -94,7 +139,12 @@ class EvaluationReportSerializer(serializers.ModelSerializer):
"help_text": "Maximum number of evaluation runs included in each report. Defaults to 200."
},
"enabled": {"help_text": "Whether report delivery is active. Disabled configs do not fire."},
- "deleted": {"help_text": "Set to true to soft-delete this report config."},
+ "deleted": {
+ "help_text": (
+ "Read-only. Report configs are soft-deleted only when their evaluation is deleted. Use "
+ "enabled=false to stop deliveries."
+ )
+ },
"report_prompt_guidance": {
"help_text": (
"Optional custom instructions appended to the AI report prompt to steer focus, scope, or "
@@ -130,6 +180,10 @@ class EvaluationReportSerializer(serializers.ModelSerializer):
},
}
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
+ super().__init__(*args, **kwargs)
+ self.created_instance = True
+
def validate_evaluation(self, value):
# Prevent creating a report in team A that references team B's evaluation:
# the FK queryset is unscoped, so a user with access to multiple teams could
@@ -147,6 +201,10 @@ class EvaluationReportSerializer(serializers.ModelSerializer):
# Allow empty for count-triggered reports; cross-field validation enforces required-when-scheduled.
if not value:
return value
+ try:
+ validate_report_schedule_rrule(value)
+ except ValueError as exc:
+ raise serializers.ValidationError(str(exc)) from exc
try:
validate_rrule(value)
except ValueError as exc:
@@ -156,6 +214,28 @@ class EvaluationReportSerializer(serializers.ModelSerializer):
def validate(self, attrs):
attrs = super().validate(attrs)
+ if (
+ self.instance is not None
+ and isinstance(self.initial_data, dict)
+ and "evaluation" in self.initial_data
+ and str(self.initial_data["evaluation"]) != str(self.instance.evaluation_id)
+ ):
+ raise serializers.ValidationError({"evaluation": "Report configs cannot be moved to another evaluation."})
+ if isinstance(self.initial_data, dict) and "deleted" in self.initial_data:
+ try:
+ submitted_deleted = serializers.BooleanField().to_internal_value(self.initial_data["deleted"])
+ except serializers.ValidationError as exc:
+ raise serializers.ValidationError({"deleted": exc.detail}) from exc
+ current_deleted = self.instance.deleted if self.instance is not None else False
+ if submitted_deleted != current_deleted:
+ raise serializers.ValidationError(
+ {
+ "deleted": (
+ "Report configs are deleted only when their evaluation is deleted. "
+ "Disable delivery with enabled=false."
+ )
+ }
+ )
# Numeric bounds for trigger_threshold / cooldown_minutes / daily_run_cap are enforced
# by the field-level min_value / max_value validators. This block only handles the
# cross-field "required" rules that the field validators can't express on their own.
@@ -174,11 +254,9 @@ class EvaluationReportSerializer(serializers.ModelSerializer):
rrule_str = attrs.get("rrule") if "rrule" in attrs else (self.instance.rrule if self.instance else "")
if not rrule_str:
raise serializers.ValidationError({"rrule": "Required when frequency is 'scheduled'."})
- starts_at = (
- attrs.get("starts_at") if "starts_at" in attrs else (self.instance.starts_at if self.instance else None)
- )
- if starts_at is None:
- raise serializers.ValidationError({"starts_at": "Required when frequency is 'scheduled'."})
+ if not self.instance or self.instance.starts_at is None:
+ attrs["starts_at"] = default_schedule_anchor()
+ attrs["timezone_name"] = "UTC"
return attrs
def validate_delivery_targets(self, value: list) -> list:
@@ -222,9 +300,29 @@ class EvaluationReportSerializer(serializers.ModelSerializer):
def create(self, validated_data):
request = self.context["request"]
team = self.context["get_team"]()
- validated_data["team"] = team
- validated_data["created_by"] = request.user
- return super().create(validated_data)
+ evaluation = validated_data["evaluation"]
+ defaults = {**validated_data, "created_by": request.user}
+ report, created = EvaluationReport.objects.get_or_create(
+ evaluation=evaluation,
+ team_id=team.id,
+ defaults=defaults,
+ )
+ self.created_instance = created
+ if created:
+ return report
+
+ for field, value in validated_data.items():
+ if field != "evaluation":
+ setattr(report, field, value)
+ if report.created_by_id is None:
+ report.created_by = request.user
+ report.save()
+ return report
+
+
+class EvaluationReportUpdateSerializer(EvaluationReportSerializer):
+ class Meta(EvaluationReportSerializer.Meta):
+ read_only_fields = [*EvaluationReportSerializer.Meta.read_only_fields, "evaluation"]
class EvaluationReportListSerializer(EvaluationReportSerializer):
@@ -298,6 +396,8 @@ class EvaluationReportViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewse
def get_serializer_class(self):
if self.action == "list" and self._is_mcp_request(self.request):
return EvaluationReportListSerializer
+ if self.action in ("update", "partial_update"):
+ return EvaluationReportUpdateSerializer
return super().get_serializer_class()
def safely_get_queryset(self, queryset: QuerySet[EvaluationReport]) -> QuerySet[EvaluationReport]:
@@ -309,17 +409,25 @@ class EvaluationReportViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewse
evaluation_id = self.request.query_params.get("evaluation")
if evaluation_id:
- queryset = queryset.filter(evaluation_id=evaluation_id)
+ query_serializer = EvaluationReportListQuerySerializer(data={"evaluation": evaluation_id})
+ query_serializer.is_valid(raise_exception=True)
+ queryset = queryset.filter(evaluation_id=query_serializer.validated_data["evaluation"])
return queryset
@llma_track_latency("llma_evaluation_reports_list")
+ @extend_schema(parameters=[EvaluationReportListQuerySerializer])
def list(self, request: Request, *args, **kwargs) -> Response:
return super().list(request, *args, **kwargs)
@llma_track_latency("llma_evaluation_reports_create")
def create(self, request: Request, *args, **kwargs) -> Response:
- return super().create(request, *args, **kwargs)
+ serializer = self.get_serializer(data=request.data)
+ serializer.is_valid(raise_exception=True)
+ self.perform_create(serializer)
+ headers = self.get_success_headers(serializer.data)
+ status_code = status.HTTP_201_CREATED if getattr(serializer, "created_instance", True) else status.HTTP_200_OK
+ return Response(serializer.data, status=status_code, headers=headers)
@llma_track_latency("llma_evaluation_reports_retrieve")
def retrieve(self, request: Request, *args, **kwargs) -> Response:
@@ -333,11 +441,22 @@ class EvaluationReportViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewse
def partial_update(self, request: Request, *args, **kwargs) -> Response:
return super().partial_update(request, *args, **kwargs)
+ @extend_schema(
+ responses={405: None},
+ description=(
+ "Evaluation report configs are deleted only when their evaluation is deleted. "
+ "Use PATCH enabled=false to stop delivery."
+ ),
+ )
+ def destroy(self, request: Request, *args, **kwargs) -> Response:
+ return super().destroy(request, *args, **kwargs)
+
def perform_create(self, serializer):
instance = serializer.save()
+ was_created = serializer.created_instance
report_user_action(
self.request.user,
- "llma evaluation report created",
+ "llma evaluation report created" if was_created else "llma evaluation report updated",
{
"evaluation_report_id": str(instance.id),
"evaluation_id": str(instance.evaluation_id),
@@ -365,13 +484,11 @@ class EvaluationReportViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewse
"delivery_targets",
"max_sample_size",
"enabled",
- "deleted",
"report_prompt_guidance",
"trigger_threshold",
"cooldown_minutes",
"daily_run_cap",
]
- is_deletion = serializer.validated_data.get("deleted") is True and not serializer.instance.deleted
changed_fields: list[str] = []
for field in tracked_fields:
@@ -383,19 +500,7 @@ class EvaluationReportViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewse
instance = serializer.save()
- if is_deletion:
- report_user_action(
- self.request.user,
- "llma evaluation report deleted",
- {
- "evaluation_report_id": str(instance.id),
- "evaluation_id": str(instance.evaluation_id),
- "was_enabled": serializer.instance.enabled,
- },
- team=self.team,
- request=self.request,
- )
- elif changed_fields:
+ if changed_fields:
event_properties: dict[str, Any] = {
"evaluation_report_id": str(instance.id),
"evaluation_id": str(instance.evaluation_id),
diff --git a/products/ai_observability/backend/api/evaluations.py b/products/ai_observability/backend/api/evaluations.py
index 6fe34baed88a..dcb1c5672f79 100644
--- a/products/ai_observability/backend/api/evaluations.py
+++ b/products/ai_observability/backend/api/evaluations.py
@@ -717,10 +717,7 @@ class EvaluationViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, Forbi
# Auto-create a default report config so reports are generated from the start.
# Defaults to count-triggered (frequency=every_n), so rrule/starts_at stay empty
# and users add email/Slack delivery targets later if they want notifications.
- EvaluationReport.objects.create(
- team=self.team,
- evaluation=instance,
- )
+ EvaluationReport.objects.get_or_create(evaluation=instance, team_id=self.team_id)
# Calculate properties for tracking
conditions = instance.conditions or []
diff --git a/products/ai_observability/backend/api/test/test_evaluation_reports.py b/products/ai_observability/backend/api/test/test_evaluation_reports.py
index 593a38581f3f..85ba6728958f 100644
--- a/products/ai_observability/backend/api/test/test_evaluation_reports.py
+++ b/products/ai_observability/backend/api/test/test_evaluation_reports.py
@@ -1,5 +1,6 @@
import datetime as dt
+from freezegun import freeze_time
from posthog.test.base import APIBaseTest
from unittest.mock import MagicMock, patch
@@ -32,6 +33,19 @@ class TestEvaluationReportApi(APIBaseTest):
)
self.base_url = f"/api/environments/{self.team.id}/llm_analytics/evaluation_reports/"
+ def _create_boolean_evaluation(self, name: str = "Other Eval") -> Evaluation:
+ return Evaluation.objects.create(
+ team=self.team,
+ name=name,
+ evaluation_type="llm_judge",
+ evaluation_config={"prompt": "test"},
+ output_type="boolean",
+ output_config={},
+ enabled=True,
+ created_by=self.user,
+ conditions=[{"id": "c1", "rollout_percentage": 100, "properties": []}],
+ )
+
def _create_report(self, **kwargs) -> EvaluationReport:
defaults = {
"team": self.team,
@@ -49,7 +63,6 @@ class TestEvaluationReportApi(APIBaseTest):
"evaluation": str(self.evaluation.id),
"frequency": "scheduled",
"rrule": "FREQ=DAILY",
- "starts_at": timezone.now().isoformat(),
"delivery_targets": [{"type": "email", "value": "[email protected]"}],
}
payload.update(overrides)
@@ -90,7 +103,7 @@ class TestEvaluationReportApi(APIBaseTest):
def test_list_reports(self):
self._create_report(rrule="FREQ=DAILY", timezone_name="UTC")
- self._create_report()
+ self._create_report(evaluation=self._create_boolean_evaluation())
response = self.client.get(self.base_url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
results = response.json()["results"]
@@ -100,6 +113,17 @@ class TestEvaluationReportApi(APIBaseTest):
for field in ("delivery_targets", "rrule", "starts_at", "timezone_name", "report_prompt_guidance"):
self.assertIn(field, first)
+ def test_list_filters_by_evaluation(self) -> None:
+ report = self._create_report()
+ self._create_report(evaluation=self._create_boolean_evaluation())
+
+ response = self.client.get(self.base_url, {"evaluation": str(self.evaluation.id)})
+
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ results = response.json()["results"]
+ self.assertEqual(len(results), 1)
+ self.assertEqual(results[0]["id"], str(report.id))
+
def test_mcp_list_returns_slim_payload(self):
self._create_report(rrule="FREQ=DAILY", timezone_name="UTC")
response = self.client.get(self.base_url, HTTP_X_POSTHOG_CLIENT="mcp")
@@ -124,7 +148,7 @@ class TestEvaluationReportApi(APIBaseTest):
def test_list_excludes_deleted(self):
self._create_report()
- self._create_report(deleted=True)
+ self._create_report(evaluation=self._create_boolean_evaluation(), deleted=True)
response = self.client.get(self.base_url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response.json()["results"]), 1)
@@ -139,6 +163,7 @@ class TestEvaluationReportApi(APIBaseTest):
self.assertEqual(report.created_by_id, self.user.id)
self.assertEqual(report.rrule, "FREQ=DAILY")
self.assertEqual(report.timezone_name, "UTC")
+ self.assertIsNotNone(report.starts_at)
def test_create_count_triggered_report_is_default(self):
response = self.client.post(
@@ -158,6 +183,27 @@ class TestEvaluationReportApi(APIBaseTest):
self.assertEqual(report.rrule, "")
self.assertIsNone(report.starts_at)
+ def test_create_updates_existing_report_for_evaluation(self):
+ report = self._create_report(delivery_targets=[])
+
+ response = self.client.post(
+ self.base_url,
+ {
+ "evaluation": str(self.evaluation.id),
+ "frequency": "scheduled",
+ "rrule": "FREQ=WEEKLY;BYDAY=MO,FR",
+ "delivery_targets": [{"type": "email", "value": "[email protected]"}],
+ },
+ format="json",
+ )
+
+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
+ self.assertEqual(EvaluationReport.objects.filter(evaluation=self.evaluation).count(), 1)
+ report.refresh_from_db()
+ self.assertEqual(report.frequency, EvaluationReport.Frequency.SCHEDULED)
+ self.assertEqual(report.rrule, "FREQ=WEEKLY;BYDAY=MO,FR")
+ self.assertEqual(report.delivery_targets, [{"type": "email", "value": "[email protected]"}])
+
def test_create_rejects_sentiment_evaluation(self):
sentiment_evaluation = self._create_sentiment_evaluation()
response = self.client.post(
@@ -222,7 +268,7 @@ class TestEvaluationReportApi(APIBaseTest):
self.assertEqual(len(response.json()["results"]), 0)
def test_create_scheduled_sets_next_delivery_date(self):
- response = self.client.post(self.base_url, self._scheduled_payload(rrule="FREQ=HOURLY"), format="json")
+ response = self.client.post(self.base_url, self._scheduled_payload(rrule="FREQ=WEEKLY;BYDAY=MO"), format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
self.assertIsNotNone(response.json()["next_delivery_date"])
@@ -235,12 +281,18 @@ class TestEvaluationReportApi(APIBaseTest):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.json().get("attr"), "rrule")
- def test_create_scheduled_requires_starts_at(self):
- payload = self._scheduled_payload()
- payload.pop("starts_at")
- response = self.client.post(self.base_url, payload, format="json")
+ def test_create_scheduled_defaults_starts_at(self):
+ with freeze_time("2026-01-15T16:37:42Z"):
+ response = self.client.post(self.base_url, self._scheduled_payload(), format="json")
+ self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
+ report = EvaluationReport.objects.get()
+ self.assertEqual(report.starts_at, dt.datetime(2026, 1, 15, 16, 0, tzinfo=dt.UTC))
+ self.assertEqual(report.timezone_name, "UTC")
+
+ def test_create_scheduled_rejects_unsupported_rrule(self):
+ response = self.client.post(self.base_url, self._scheduled_payload(rrule="FREQ=HOURLY"), format="json")
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
- self.assertEqual(response.json().get("attr"), "starts_at")
+ self.assertEqual(response.json().get("attr"), "rrule")
def test_create_rejects_invalid_rrule(self):
response = self.client.post(self.base_url, self._scheduled_payload(rrule="NOT_AN_RRULE"), format="json")
@@ -419,28 +471,61 @@ class TestEvaluationReportApi(APIBaseTest):
def test_update_report(self):
report = self._create_report()
+ with freeze_time("2026-01-15T16:37:42Z"):
+ response = self.client.patch(
+ f"{self.base_url}{report.id}/",
+ {"frequency": "scheduled", "rrule": "FREQ=WEEKLY;BYDAY=MO"},
+ format="json",
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
+ report.refresh_from_db()
+ self.assertEqual(report.frequency, "scheduled")
+ self.assertEqual(report.rrule, "FREQ=WEEKLY;BYDAY=MO")
+ self.assertEqual(report.starts_at, dt.datetime(2026, 1, 15, 16, 0, tzinfo=dt.UTC))
+ self.assertEqual(report.timezone_name, "UTC")
+
+ def test_update_allows_full_resource_echo_for_unchanged_read_only_fields(self) -> None:
+ report = self._create_report()
+ retrieve_response = self.client.get(f"{self.base_url}{report.id}/")
+ self.assertEqual(retrieve_response.status_code, status.HTTP_200_OK)
+ payload = retrieve_response.json()
+ payload["enabled"] = False
+
+ response = self.client.patch(f"{self.base_url}{report.id}/", payload, format="json")
+
+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
+ report.refresh_from_db()
+ self.assertEqual(report.evaluation_id, self.evaluation.id)
+ self.assertFalse(report.deleted)
+ self.assertFalse(report.enabled)
+
+ def test_update_rejects_evaluation_reparent(self) -> None:
+ report = self._create_report()
+ other_evaluation = self._create_boolean_evaluation()
+
response = self.client.patch(
f"{self.base_url}{report.id}/",
- {"frequency": "scheduled", "rrule": "FREQ=WEEKLY;BYDAY=MO", "starts_at": timezone.now().isoformat()},
+ {"evaluation": str(other_evaluation.id)},
format="json",
)
- self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
+
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
+ self.assertEqual(response.json().get("attr"), "evaluation")
report.refresh_from_db()
- self.assertEqual(report.frequency, "scheduled")
- self.assertEqual(report.rrule, "FREQ=WEEKLY;BYDAY=MO")
+ self.assertEqual(report.evaluation_id, self.evaluation.id)
def test_delete_returns_405(self):
report = self._create_report()
response = self.client.delete(f"{self.base_url}{report.id}/")
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
- def test_soft_delete_via_patch(self):
+ def test_rejects_soft_delete_via_patch(self):
report = self._create_report()
response = self.client.patch(f"{self.base_url}{report.id}/", {"deleted": True}, format="json")
- self.assertEqual(response.status_code, status.HTTP_200_OK)
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
report.refresh_from_db()
- self.assertTrue(report.deleted)
- self.assertEqual(EvaluationReport.objects.filter(deleted=False).count(), 0)
+ self.assertFalse(report.deleted)
+ self.assertEqual(EvaluationReport.objects.filter(deleted=False).count(), 1)
def test_runs_action_returns_paginated_shape(self):
report = self._create_report()
@@ -520,10 +605,9 @@ class TestEvaluationReportApi(APIBaseTest):
self.assertEqual(event_name, "llma evaluation report updated")
@patch("products.ai_observability.backend.api.evaluation_reports.report_user_action")
- def test_soft_delete_reports_user_action(self, mock_report: MagicMock) -> None:
+ def test_rejected_soft_delete_does_not_report_user_action(self, mock_report: MagicMock) -> None:
report = self._create_report()
mock_report.reset_mock()
response = self.client.patch(f"{self.base_url}{report.id}/", {"deleted": True}, format="json")
- self.assertEqual(response.status_code, status.HTTP_200_OK)
- event_name = mock_report.call_args_list[0].args[1]
- self.assertEqual(event_name, "llma evaluation report deleted")
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
+ mock_report.assert_not_called()
diff --git a/products/ai_observability/backend/api/test/test_evaluations.py b/products/ai_observability/backend/api/test/test_evaluations.py
index 3e4a8a71cc4a..cae0f6fff737 100644
--- a/products/ai_observability/backend/api/test/test_evaluations.py
+++ b/products/ai_observability/backend/api/test/test_evaluations.py
@@ -221,10 +221,10 @@ class TestEvaluationConfigsApi(APIBaseTest):
def test_evaluation_rollback_when_auto_report_fails(self):
"""
perform_create wraps the Evaluation save and the EvaluationReport auto-create in
- transaction.atomic(). If the report insert raises, the evaluation must not persist.
+ transaction.atomic(). If the report create raises, the evaluation must not persist.
"""
with patch(
- "products.ai_observability.backend.api.evaluations.EvaluationReport.objects.create",
+ "products.ai_observability.backend.api.evaluations.EvaluationReport.objects.get_or_create",
side_effect=RuntimeError("boom"),
):
response = self.client.post(
diff --git a/products/ai_observability/backend/migrations/0018_deduplicate_evaluation_reports.py b/products/ai_observability/backend/migrations/0018_deduplicate_evaluation_reports.py
new file mode 100644
index 000000000000..2decd6566f2f
--- /dev/null
+++ b/products/ai_observability/backend/migrations/0018_deduplicate_evaluation_reports.py
@@ -0,0 +1,34 @@
+from django.db import migrations
+
+DEDUPLICATE_REPORT_RUNS_SQL = """
+-- migration-analyzer: safe reason=ai observability evaluation reports are limited-use; UPDATE only rewires runs linked to duplicate evaluation configs
+WITH ranked_reports AS (
+ SELECT
+ id,
+ FIRST_VALUE(id) OVER (
+ PARTITION BY evaluation_id
+ ORDER BY deleted ASC, enabled DESC, created_at DESC NULLS LAST, id DESC
+ ) AS keep_id,
+ ROW_NUMBER() OVER (
+ PARTITION BY evaluation_id
+ ORDER BY deleted ASC, enabled DESC, created_at DESC NULLS LAST, id DESC
+ ) AS row_number
+ FROM llm_analytics_evaluationreport
+)
+UPDATE llm_analytics_evaluationreportrun AS run
+SET report_id = ranked_reports.keep_id
+FROM ranked_reports
+WHERE ranked_reports.row_number > 1
+ AND run.report_id = ranked_reports.id;
+"""
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("ai_observability", "0017_relabel_terminal_status_reasons"),
+ ]
+
+ operations = [
+ # Preserve generated report history before enforcing the one-config-per-evaluation invariant.
+ migrations.RunSQL(DEDUPLICATE_REPORT_RUNS_SQL, reverse_sql=migrations.RunSQL.noop),
+ ]
diff --git a/products/ai_observability/backend/migrations/0019_delete_duplicate_evaluation_reports.py b/products/ai_observability/backend/migrations/0019_delete_duplicate_evaluation_reports.py
new file mode 100644
index 000000000000..88074395b118
--- /dev/null
+++ b/products/ai_observability/backend/migrations/0019_delete_duplicate_evaluation_reports.py
@@ -0,0 +1,28 @@
+from django.db import migrations
+
+DELETE_DUPLICATE_REPORTS_SQL = """
+-- migration-analyzer: safe reason=ai observability evaluation reports are limited-use; DELETE only removes duplicate configs after runs are rewired
+WITH ranked_reports AS (
+ SELECT
+ id,
+ ROW_NUMBER() OVER (
+ PARTITION BY evaluation_id
+ ORDER BY deleted ASC, enabled DESC, created_at DESC NULLS LAST, id DESC
+ ) AS row_number
+ FROM llm_analytics_evaluationreport
+)
+DELETE FROM llm_analytics_evaluationreport AS report
+USING ranked_reports
+WHERE ranked_reports.row_number > 1
+ AND report.id = ranked_reports.id;
+"""
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("ai_observability", "0018_deduplicate_evaluation_reports"),
+ ]
+
+ operations = [
+ migrations.RunSQL(DELETE_DUPLICATE_REPORTS_SQL, reverse_sql=migrations.RunSQL.noop),
+ ]
diff --git a/products/ai_observability/backend/migrations/0020_unique_evaluation_report_per_evaluation.py b/products/ai_observability/backend/migrations/0020_unique_evaluation_report_per_evaluation.py
new file mode 100644
index 000000000000..957e192bf3e4
--- /dev/null
+++ b/products/ai_observability/backend/migrations/0020_unique_evaluation_report_per_evaluation.py
@@ -0,0 +1,33 @@
+from django.db import migrations, models
+
+from posthog.migration_helpers import CreateIndexConcurrently
+
+
+class Migration(migrations.Migration):
+ atomic = False
+
+ dependencies = [
+ ("ai_observability", "0019_delete_duplicate_evaluation_reports"),
+ ]
+
+ operations = [
+ migrations.SeparateDatabaseAndState(
+ database_operations=[
+ CreateIndexConcurrently(
+ index_name="unique_evaluation_report_per_evaluation",
+ table_name="llm_analytics_evaluationreport",
+ columns="(evaluation_id)",
+ unique=True,
+ ),
+ ],
+ state_operations=[
+ migrations.AddConstraint(
+ model_name="evaluationreport",
+ constraint=models.UniqueConstraint(
+ fields=["evaluation"],
+ name="unique_evaluation_report_per_evaluation",
+ ),
+ ),
+ ],
+ ),
+ ]
diff --git a/products/ai_observability/backend/migrations/max_migration.txt b/products/ai_observability/backend/migrations/max_migration.txt
index 154ae8dad143..b93ed6c7acbc 100644
--- a/products/ai_observability/backend/migrations/max_migration.txt
+++ b/products/ai_observability/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0017_relabel_terminal_status_reasons
+0020_unique_evaluation_report_per_evaluation
diff --git a/products/ai_observability/backend/models/evaluation_reports.py b/products/ai_observability/backend/models/evaluation_reports.py
index 09f58ca90d30..8129e6421535 100644
--- a/products/ai_observability/backend/models/evaluation_reports.py
+++ b/products/ai_observability/backend/models/evaluation_reports.py
@@ -33,7 +33,7 @@ class EvaluationReport(UUIDTModel):
# Count-based: fire every N new eval results, subject to cooldown + daily cap.
EVERY_N = "every_n"
- TRIGGER_THRESHOLD_MIN = 10
+ TRIGGER_THRESHOLD_MIN = 100
TRIGGER_THRESHOLD_MAX = 10_000
TRIGGER_THRESHOLD_DEFAULT = 100
COOLDOWN_MINUTES_MIN = 60
@@ -52,6 +52,9 @@ class EvaluationReport(UUIDTModel):
models.Index(fields=["team", "-created_at", "id"]),
models.Index(fields=["next_delivery_date", "enabled", "deleted"]),
]
+ constraints = [
+ models.UniqueConstraint(fields=["evaluation"], name="unique_evaluation_report_per_evaluation"),
+ ]
team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
evaluation = models.ForeignKey(
diff --git a/products/ai_observability/backend/models/test/test_evaluation_reports.py b/products/ai_observability/backend/models/test/test_evaluation_reports.py
index 7671f5f9a9fe..02522f8662ce 100644
--- a/products/ai_observability/backend/models/test/test_evaluation_reports.py
+++ b/products/ai_observability/backend/models/test/test_evaluation_reports.py
@@ -158,34 +158,25 @@ class TestEvaluationReportDeletionCascade(BaseTest):
self.assertNotIn(orphaned.id, deliverable_ids)
def test_deliverable_excludes_disabled_and_deleted_reports(self):
- evaluation = self._create_evaluation()
- disabled = self._report_for(evaluation, enabled=False)
- deleted = self._report_for(evaluation, deleted=True)
- live = self._report_for(evaluation)
+ disabled = self._report_for(self._create_evaluation(), enabled=False)
+ deleted = self._report_for(self._create_evaluation(), deleted=True)
+ live = self._report_for(self._create_evaluation())
deliverable_ids = set(EvaluationReport.objects.deliverable().values_list("id", flat=True))
self.assertEqual(deliverable_ids, {live.id})
self.assertNotIn(disabled.id, deliverable_ids)
self.assertNotIn(deleted.id, deliverable_ids)
- def test_deleting_evaluation_retires_its_reports(self):
+ def test_deleting_evaluation_retires_its_report(self):
evaluation = self._create_evaluation()
- scheduled = self._report_for(evaluation)
- count_triggered = self._report_for(
- evaluation,
- frequency=EvaluationReport.Frequency.EVERY_N,
- trigger_threshold=100,
- rrule="",
- starts_at=None,
- )
+ report = self._report_for(evaluation)
evaluation.deleted = True
evaluation.save()
- for report in (scheduled, count_triggered):
- report.refresh_from_db()
- self.assertTrue(report.deleted)
- self.assertFalse(report.enabled)
+ report.refresh_from_db()
+ self.assertTrue(report.deleted)
+ self.assertFalse(report.enabled)
def test_deleting_evaluation_leaves_other_evaluations_reports_alone(self):
keep = self._report_for(self._create_evaluation())
diff --git a/products/ai_observability/frontend/evaluations/AIObservabilityEvaluation.tsx b/products/ai_observability/frontend/evaluations/AIObservabilityEvaluation.tsx
index 01572e0a2e85..ac65a940a60d 100644
--- a/products/ai_observability/frontend/evaluations/AIObservabilityEvaluation.tsx
+++ b/products/ai_observability/frontend/evaluations/AIObservabilityEvaluation.tsx
@@ -405,8 +405,7 @@ export function AIObservabilityEvaluation(): JSX.Element {
),
},
!isNewEvaluation &&
- isReportableEvaluation &&
- !!featureFlags[FEATURE_FLAGS.LLM_ANALYTICS_EVALUATIONS_REPORTS] && {
+ isReportableEvaluation && {
key: 'reports',
label: 'Reports',
'data-attr': 'llma-evaluation-reports-tab',
@@ -622,21 +621,17 @@ export function AIObservabilityEvaluation(): JSX.Element {
</div>
{/* Scheduled Reports (inline config for new evaluations) */}
- {isNewEvaluation &&
- isReportableEvaluation &&
- featureFlags[FEATURE_FLAGS.LLM_ANALYTICS_EVALUATIONS_REPORTS] && (
- <EvaluationReportConfig evaluationId="new" />
- )}
+ {isNewEvaluation && isReportableEvaluation && (
+ <EvaluationReportConfig evaluationId="new" />
+ )}
</Form>
{/* Scheduled Reports (for existing evaluations, outside the form) */}
- {!isNewEvaluation &&
- isReportableEvaluation &&
- featureFlags[FEATURE_FLAGS.LLM_ANALYTICS_EVALUATIONS_REPORTS] && (
- <div className="mt-6">
- <EvaluationReportConfig evaluationId={evaluation.id} />
- </div>
- )}
+ {!isNewEvaluation && isReportableEvaluation && (
+ <div className="mt-6">
+ <EvaluationReportConfig evaluationId={evaluation.id} />
+ </div>
+ )}
</div>
),
},
diff --git a/products/ai_observability/frontend/evaluations/components/EvaluationReportConfig.stories.tsx b/products/ai_observability/frontend/evaluations/components/EvaluationReportConfig.stories.tsx
index 2adbf3014a49..a0d566d6d685 100644
--- a/products/ai_observability/frontend/evaluations/components/EvaluationReportConfig.stories.tsx
+++ b/products/ai_observability/frontend/evaluations/components/EvaluationReportConfig.stories.tsx
@@ -3,6 +3,7 @@ import { useState } from 'react'
import { FEATURE_FLAGS } from 'lib/constants'
+import type { ReportScheduleCadence, ReportScheduleWeekday } from '../evaluationReportLogic'
import { ScheduleConfig } from './EvaluationReportConfig'
type Story = StoryObj<typeof ScheduleConfig>
@@ -17,18 +18,22 @@ const meta: Meta<typeof ScheduleConfig> = {
export default meta
function Template(): JSX.Element {
- const [rrule, setRrule] = useState('FREQ=DAILY')
- const [startsAt, setStartsAt] = useState<string | null>('2026-01-15T09:30:00.000Z')
- const [timezoneName, setTimezoneName] = useState('UTC')
+ const [cadence, setCadence] = useState<ReportScheduleCadence>('weekly')
+ const [weekdays, setWeekdays] = useState<ReportScheduleWeekday[]>(['MO', 'FR'])
+ const toggleWeekday = (weekday: ReportScheduleWeekday): void => {
+ setWeekdays((current) =>
+ current.includes(weekday)
+ ? current.filter((currentWeekday) => currentWeekday !== weekday)
+ : [...current, weekday]
+ )
+ }
return (
<div className="w-100">
<ScheduleConfig
- rrule={rrule}
- startsAt={startsAt}
- timezoneName={timezoneName}
- onRruleChange={setRrule}
- onStartsAtChange={setStartsAt}
- onTimezoneChange={setTimezoneName}
+ cadence={cadence}
+ weekdays={weekdays}
+ onCadenceChange={setCadence}
+ onWeekdayToggle={toggleWeekday}
/>
</div>
)
diff --git a/products/ai_observability/frontend/evaluations/components/EvaluationReportConfig.tsx b/products/ai_observability/frontend/evaluations/components/EvaluationReportConfig.tsx
index fd91b9200fff..72abb757fca6 100644
--- a/products/ai_observability/frontend/evaluations/components/EvaluationReportConfig.tsx
+++ b/products/ai_observability/frontend/evaluations/components/EvaluationReportConfig.tsx
@@ -1,10 +1,8 @@
import { useActions, useValues } from 'kea'
-import { LemonDialog, LemonInput, LemonSelect, LemonSwitch, LemonTag, LemonTextArea } from '@posthog/lemon-ui'
+import { LemonButton, LemonInput, LemonSegmentedButton, LemonSwitch, LemonTag, LemonTextArea } from '@posthog/lemon-ui'
import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'
-import { DatePicker } from 'lib/components/DatePicker/DatePicker'
-import { dayjs } from 'lib/dayjs'
import { integrationsLogic } from 'lib/integrations/integrationsLogic'
import { SlackChannelPicker, SlackNotConfiguredBanner } from 'lib/integrations/SlackIntegrationHelpers'
@@ -12,8 +10,11 @@ import {
COOLDOWN_HOURS_MAX,
COOLDOWN_HOURS_MIN,
evaluationReportLogic,
- TRIGGER_THRESHOLD_DEFAULT,
+ TRIGGER_THRESHOLD_MAX,
+ TRIGGER_THRESHOLD_MIN,
+ WEEKDAY_OPTIONS,
} from '../evaluationReportLogic'
+import type { ReportScheduleCadence, ReportScheduleWeekday } from '../evaluationReportLogic'
const GUIDANCE_PLACEHOLDER =
"Optional guidance for the report agent. e.g. 'Focus on cost regressions across models', 'Compare latency between gpt-4o-mini and claude-sonnet', 'Keep it to 2 sections max'"
@@ -23,57 +24,50 @@ const FREQUENCY_OPTIONS = [
{ value: 'scheduled' as const, label: 'On a schedule' },
]
-const RRULE_PLACEHOLDER = 'FREQ=DAILY'
-const RRULE_EXAMPLES = 'Examples: FREQ=DAILY · FREQ=WEEKLY;BYDAY=MO,FR · FREQ=HOURLY;INTERVAL=6'
-
-const TRIGGER_THRESHOLD_MIN = 10
-const TRIGGER_THRESHOLD_MAX = 10_000
+const SCHEDULE_OPTIONS = [
+ { value: 'daily' as const, label: 'Daily' },
+ { value: 'weekly' as const, label: 'Weekly' },
+]
-/** RRULE + starts_at + timezone inputs shown when frequency is 'scheduled'.
- * Accepts a raw RRULE string (RFC 5545) — matches the HogFlowSchedule contract in
- * products/workflows. A richer picker (RecurringSchedulePicker) can replace this later. */
+/** Daily/weekly schedule controls shown when frequency is 'scheduled'. */
export function ScheduleConfig({
- rrule,
- startsAt,
- timezoneName,
- onRruleChange,
- onStartsAtChange,
- onTimezoneChange,
+ cadence,
+ weekdays,
+ onCadenceChange,
+ onWeekdayToggle,
}: {
- rrule: string
- startsAt: string | null
- timezoneName: string
- onRruleChange: (value: string) => void
- onStartsAtChange: (value: string | null) => void
- onTimezoneChange: (value: string) => void
+ cadence: ReportScheduleCadence
+ weekdays: ReportScheduleWeekday[]
+ onCadenceChange: (value: ReportScheduleCadence) => void
+ onWeekdayToggle: (value: ReportScheduleWeekday) => void
}): JSX.Element {
return (
<div className="space-y-3">
<div>
- <label className="font-semibold text-sm">Schedule (RRULE)</label>
- <LemonInput value={rrule} onChange={onRruleChange} placeholder={RRULE_PLACEHOLDER} fullWidth />
- <p className="text-xs text-muted mt-1">{RRULE_EXAMPLES}</p>
- </div>
- <div>
- <label className="font-semibold text-sm">Starts at</label>
- <DatePicker
- format="MMMM D, YYYY h:mm A"
- clearable
- value={startsAt ? dayjs(startsAt) : null}
- onChange={(d) => onStartsAtChange(d ? d.toISOString() : null)}
- granularity="minute"
- showTimeToggle={false}
- maxDate={dayjs().add(5, 'year')}
- />
- <p className="text-xs text-muted mt-1">
- Anchor datetime used when expanding the RRULE. Used as the first occurrence for plain frequencies.
- </p>
- </div>
- <div>
- <label className="font-semibold text-sm">Timezone</label>
- <LemonInput value={timezoneName} onChange={onTimezoneChange} placeholder="UTC" fullWidth />
- <p className="text-xs text-muted mt-1">IANA timezone name (e.g. UTC, America/New_York).</p>
+ <label className="font-semibold text-sm">Schedule</label>
+ <LemonSegmentedButton value={cadence} onChange={onCadenceChange} options={SCHEDULE_OPTIONS} />
</div>
+ {cadence === 'weekly' && (
+ <div>
+ <label className="font-semibold text-sm">Days of the week</label>
+ <div className="flex flex-wrap gap-1 mt-1">
+ {WEEKDAY_OPTIONS.map((option) => {
+ const selected = weekdays.includes(option.value)
+ return (
+ <LemonButton
+ key={option.value}
+ size="small"
+ type={selected ? 'primary' : 'secondary'}
+ active={selected}
+ onClick={() => onWeekdayToggle(option.value)}
+ >
+ {option.label}
+ </LemonButton>
+ )
+ })}
+ </div>
+ </div>
+ )}
</div>
)
}
@@ -188,9 +182,8 @@ function ReportFormFields({ evaluationId }: { evaluationId: string }): JSX.Eleme
const { configDraft } = useValues(evaluationReportLogic({ evaluationId }))
const {
setDraftFrequency,
- setDraftRrule,
- setDraftStartsAt,
- setDraftTimezoneName,
+ setDraftScheduleCadence,
+ toggleDraftScheduleWeekday,
setDraftEmailValue,
setDraftSlackIntegrationId,
setDraftSlackChannelValue,
@@ -203,9 +196,9 @@ function ReportFormFields({ evaluationId }: { evaluationId: string }): JSX.Eleme
<div className="space-y-4 mt-4">
<div>
<label className="font-semibold text-sm">Frequency</label>
- <LemonSelect
+ <LemonSegmentedButton
value={configDraft.frequency}
- onChange={(val) => val && setDraftFrequency(val)}
+ onChange={setDraftFrequency}
options={FREQUENCY_OPTIONS}
fullWidth
/>
@@ -218,12 +211,10 @@ function ReportFormFields({ evaluationId }: { evaluationId: string }): JSX.Eleme
)}
{configDraft.frequency === 'scheduled' && (
<ScheduleConfig
- rrule={configDraft.rrule}
- startsAt={configDraft.startsAt}
- timezoneName={configDraft.timezoneName}
- onRruleChange={setDraftRrule}
- onStartsAtChange={setDraftStartsAt}
- onTimezoneChange={setDraftTimezoneName}
+ cadence={configDraft.scheduleCadence}
+ weekdays={configDraft.scheduleWeekdays}
+ onCadenceChange={setDraftScheduleCadence}
+ onWeekdayToggle={toggleDraftScheduleWeekday}
/>
)}
<DeliveryTargetsConfig
@@ -272,7 +263,7 @@ function PendingReportConfig({ evaluationId }: { evaluationId: string }): JSX.El
label={configDraft.enabled ? 'Enabled' : 'Disabled'}
/>
</div>
- {configDraft.enabled && <ReportFormFields evaluationId={evaluationId} />}
+ <ReportFormFields evaluationId={evaluationId} />
</div>
)
}
@@ -280,34 +271,14 @@ function PendingReportConfig({ evaluationId }: { evaluationId: string }): JSX.El
/** Toggle-based report management for existing evaluations.
* The "Save changes" button at the top of the evaluation page persists any
* draft updates — see llmEvaluationLogic.saveEvaluation, which forwards
- * the draft to persistReportDraft. Disabling the toggle with a saved report
- * is still an immediate destructive action (handled via the dialog) rather
- * than a staged save. */
+ * the draft to persistReportDraft. Disabling the toggle is a staged config
+ * update that sets enabled=false, preserving the report config row. */
function ExistingReportConfig({ evaluationId }: { evaluationId: string }): JSX.Element {
const logic = evaluationReportLogic({ evaluationId })
const { activeReport, reportsLoading, configDraft, isConfigDirty } = useValues(logic)
- const { deleteReport, setDraftEnabled } = useActions(logic)
-
- const isEnabled = !!activeReport || configDraft.enabled
+ const { setDraftEnabled } = useActions(logic)
- const handleToggle = (checked: boolean): void => {
- if (checked) {
- setDraftEnabled(true)
- } else if (activeReport) {
- LemonDialog.open({
- title: 'Disable scheduled reports?',
- description: 'This will stop all future report deliveries. Past reports will be preserved.',
- primaryButton: {
- children: 'Disable',
- status: 'danger',
- onClick: () => deleteReport(activeReport.id),
- },
- secondaryButton: { children: 'Cancel' },
- })
- } else {
- setDraftEnabled(false)
- }
- }
+ const isEnabled = configDraft.enabled
return (
<div className="bg-bg-light border rounded p-6">
@@ -324,7 +295,7 @@ function ExistingReportConfig({ evaluationId }: { evaluationId: string }): JSX.E
</div>
<LemonSwitch
checked={isEnabled}
- onChange={handleToggle}
+ onChange={setDraftEnabled}
bordered
loading={reportsLoading}
label={isEnabled ? 'Enabled' : 'Disabled'}
@@ -336,13 +307,13 @@ function ExistingReportConfig({ evaluationId }: { evaluationId: string }): JSX.E
<ReportFormFields evaluationId={evaluationId} />
{configDraft.frequency === 'every_n'
? (() => {
- const cooldownHours = Math.max(1, Math.round((activeReport.cooldown_minutes ?? 60) / 60))
+ const cooldownHours = configDraft.cooldownHours
return (
<div className="text-sm text-muted mt-4">
- A report will be generated when{' '}
- {activeReport.trigger_threshold ?? TRIGGER_THRESHOLD_DEFAULT} new evaluation
- results arrive, at most once every {cooldownHours}{' '}
- {cooldownHours === 1 ? 'hour' : 'hours'}. Checked every 5 minutes.
+ {configDraft.enabled ? 'A report' : 'When enabled, a report'} will be generated
+ when {configDraft.triggerThreshold} new evaluation results arrive, at most once
+ every {cooldownHours} {cooldownHours === 1 ? 'hour' : 'hours'}. Checked every 5
+ minutes.
</div>
)
})()
@@ -354,7 +325,7 @@ function ExistingReportConfig({ evaluationId }: { evaluationId: string }): JSX.E
<p className="text-xs text-muted m-0 mt-2">Generated reports appear in the Reports tab.</p>
</>
) : (
- configDraft.enabled && <ReportFormFields evaluationId={evaluationId} />
+ <ReportFormFields evaluationId={evaluationId} />
)}
</div>
)
diff --git a/products/ai_observability/frontend/evaluations/evaluationReportLogic.ts b/products/ai_observability/frontend/evaluations/evaluationReportLogic.ts
index 8eef87da8371..b1166ba24be6 100644
--- a/products/ai_observability/frontend/evaluations/evaluationReportLogic.ts
+++ b/products/ai_observability/frontend/evaluations/evaluationReportLogic.ts
@@ -1,10 +1,16 @@
import { actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
-import api from 'lib/api'
import { lemonToast } from 'lib/lemon-ui/LemonToast'
import { teamLogic } from 'scenes/teamLogic'
+import {
+ llmAnalyticsEvaluationReportsCreate,
+ llmAnalyticsEvaluationReportsGenerateCreate,
+ llmAnalyticsEvaluationReportsList,
+ llmAnalyticsEvaluationReportsPartialUpdate,
+ llmAnalyticsEvaluationReportsRunsList,
+} from '../generated/api'
import type { evaluationReportLogicType } from './evaluationReportLogicType'
import type {
EvaluationReport,
@@ -13,18 +19,23 @@ import type {
EvaluationReportRun,
} from './types'
+type EvaluationReportCreateBody = Parameters<typeof llmAnalyticsEvaluationReportsCreate>[1]
+type EvaluationReportPatchBody = Parameters<typeof llmAnalyticsEvaluationReportsPartialUpdate>[2]
+
export interface EvaluationReportLogicProps {
evaluationId: string
}
+export type ReportScheduleCadence = 'daily' | 'weekly'
+export type ReportScheduleWeekday = 'MO' | 'TU' | 'WE' | 'TH' | 'FR' | 'SA' | 'SU'
+
/** Draft state for the report config form — used for both the create-new-evaluation path
* (keyed as 'new') and the edit-existing-evaluation path (keyed by the real evaluation id). */
export interface ReportConfigDraft {
enabled: boolean
frequency: EvaluationReportFrequency
- rrule: string
- startsAt: string | null
- timezoneName: string
+ scheduleCadence: ReportScheduleCadence
+ scheduleWeekdays: ReportScheduleWeekday[]
emailValue: string
slackIntegrationId: number | null
slackChannelValue: string
@@ -33,19 +44,32 @@ export interface ReportConfigDraft {
cooldownHours: number
}
+export const TRIGGER_THRESHOLD_MIN = 100
export const TRIGGER_THRESHOLD_DEFAULT = 100
+export const TRIGGER_THRESHOLD_MAX = 10_000
export const COOLDOWN_HOURS_DEFAULT = 1
export const COOLDOWN_HOURS_MIN = 1
export const COOLDOWN_HOURS_MAX = 24
export const DEFAULT_RRULE = 'FREQ=DAILY'
-export const DEFAULT_TIMEZONE = 'UTC'
+export const DEFAULT_SCHEDULE_CADENCE: ReportScheduleCadence = 'daily'
+export const DEFAULT_WEEKLY_DAYS: ReportScheduleWeekday[] = ['MO']
+export const WEEKDAY_OPTIONS: { value: ReportScheduleWeekday; label: string }[] = [
+ { value: 'MO', label: 'Mon' },
+ { value: 'TU', label: 'Tue' },
+ { value: 'WE', label: 'Wed' },
+ { value: 'TH', label: 'Thu' },
+ { value: 'FR', label: 'Fri' },
+ { value: 'SA', label: 'Sat' },
+ { value: 'SU', label: 'Sun' },
+]
+
+const WEEKDAY_ORDER = WEEKDAY_OPTIONS.map((option) => option.value)
const DEFAULT_CONFIG_DRAFT: ReportConfigDraft = {
enabled: true,
frequency: 'every_n',
- rrule: '',
- startsAt: null,
- timezoneName: DEFAULT_TIMEZONE,
+ scheduleCadence: DEFAULT_SCHEDULE_CADENCE,
+ scheduleWeekdays: DEFAULT_WEEKLY_DAYS,
emailValue: '',
slackIntegrationId: null,
slackChannelValue: '',
@@ -54,18 +78,50 @@ const DEFAULT_CONFIG_DRAFT: ReportConfigDraft = {
cooldownHours: COOLDOWN_HOURS_DEFAULT,
}
+function normalizeScheduleWeekdays(weekdays: ReportScheduleWeekday[]): ReportScheduleWeekday[] {
+ const selected = new Set(weekdays)
+ const normalized = WEEKDAY_ORDER.filter((weekday) => selected.has(weekday))
+ return normalized.length > 0 ? normalized : DEFAULT_WEEKLY_DAYS
+}
+
+function rruleFromSchedule(cadence: ReportScheduleCadence, weekdays: ReportScheduleWeekday[]): string {
+ if (cadence === 'daily') {
+ return DEFAULT_RRULE
+ }
+ return `FREQ=WEEKLY;BYDAY=${normalizeScheduleWeekdays(weekdays).join(',')}`
+}
+
+function scheduleFromRrule(rrule: string): {
+ cadence: ReportScheduleCadence
+ weekdays: ReportScheduleWeekday[]
+} {
+ if (rrule.startsWith('FREQ=WEEKLY')) {
+ const byday = rrule
+ .split(';')
+ .find((part) => part.startsWith('BYDAY='))
+ ?.replace('BYDAY=', '')
+ const weekdays = normalizeScheduleWeekdays(
+ (byday?.split(',') ?? []).filter((day): day is ReportScheduleWeekday =>
+ WEEKDAY_ORDER.includes(day as ReportScheduleWeekday)
+ )
+ )
+ return { cadence: 'weekly', weekdays }
+ }
+ return { cadence: 'daily', weekdays: DEFAULT_WEEKLY_DAYS }
+}
+
function draftFromReport(report: EvaluationReport): ReportConfigDraft {
const emailTarget = report.delivery_targets.find((t) => t.type === 'email')
const slackTarget = report.delivery_targets.find((t) => t.type === 'slack')
+ const schedule = scheduleFromRrule(report.rrule ?? '')
// Normalise here so the dirty check (which compares against draft.emailValue
// that buildDeliveryTargets later trims) doesn't fire a false positive when
// the stored value is surrounded by whitespace.
return {
- enabled: true,
+ enabled: report.enabled,
frequency: report.frequency,
- rrule: report.rrule ?? '',
- startsAt: report.starts_at ?? null,
- timezoneName: report.timezone_name ?? DEFAULT_TIMEZONE,
+ scheduleCadence: schedule.cadence,
+ scheduleWeekdays: schedule.weekdays,
emailValue: (emailTarget?.value ?? '').trim(),
slackIntegrationId: slackTarget?.integration_id ?? null,
slackChannelValue: slackTarget?.channel ?? '',
@@ -97,14 +153,13 @@ function buildReportUpdatePayload(
targets: EvaluationReportDeliveryTarget[]
): Record<string, unknown> {
const data: Record<string, unknown> = {
+ enabled: draft.enabled,
frequency: draft.frequency,
delivery_targets: targets,
report_prompt_guidance: draft.reportPromptGuidance,
}
if (draft.frequency === 'scheduled') {
- data.rrule = draft.rrule
- data.starts_at = draft.startsAt
- data.timezone_name = draft.timezoneName
+ data.rrule = rruleFromSchedule(draft.scheduleCadence, draft.scheduleWeekdays)
}
if (draft.frequency === 'every_n') {
data.trigger_threshold = draft.triggerThreshold
@@ -129,12 +184,10 @@ function buildReportCreatePayload(
frequency: draft.frequency,
delivery_targets: targets,
report_prompt_guidance: draft.reportPromptGuidance,
- enabled: true,
+ enabled: draft.enabled,
}
if (draft.frequency === 'scheduled') {
- body.rrule = draft.rrule
- body.starts_at = draft.startsAt
- body.timezone_name = draft.timezoneName
+ body.rrule = rruleFromSchedule(draft.scheduleCadence, draft.scheduleWeekdays)
}
if (draft.frequency === 'every_n') {
body.trigger_threshold = draft.triggerThreshold
@@ -143,6 +196,18 @@ function buildReportCreatePayload(
return body
}
+async function loadReportsForEvaluation(teamId: number, evaluationId: string): Promise<EvaluationReport[]> {
+ const response = await llmAnalyticsEvaluationReportsList(teamId.toString(), { evaluation: evaluationId })
+ return (response.results || []) as EvaluationReport[]
+}
+
+function requireCurrentTeamId(teamId: number | null): number {
+ if (teamId === null) {
+ throw new Error('Current team is not loaded')
+ }
+ return teamId
+}
+
/** Inline persistor used by the parent evaluation save flow so the single
* "Save changes" button at the top of the page commits both the evaluation
* and the (optional) scheduled report. Mirrors the saveDraft listener but
@@ -156,31 +221,19 @@ export async function persistReportDraft(
activeReport: EvaluationReport | null
): Promise<boolean> {
const targets = buildDeliveryTargets(draft)
- if (activeReport) {
- // Match the inner Save button's validation so the main Save flow
- // doesn't silently clear all delivery targets on an existing report.
- if (targets.length === 0) {
- lemonToast.warning('Scheduled report not saved — add at least one delivery target.')
- return false
- }
- // nosemgrep: prefer-codegen-api
- await api.update(
- `api/environments/${teamId}/llm_analytics/evaluation_reports/${activeReport.id}/`,
- buildReportUpdatePayload(draft, activeReport, targets)
+ const report = activeReport ?? (await loadReportsForEvaluation(teamId, evaluationId))[0] ?? null
+ if (report) {
+ await llmAnalyticsEvaluationReportsPartialUpdate(
+ teamId.toString(),
+ report.id,
+ buildReportUpdatePayload(draft, report, targets) as EvaluationReportPatchBody
)
return true
}
- // No active report yet — create only if the draft has savable content.
- if (!draft.enabled) {
- return false
- }
- if (targets.length === 0 && draft.reportPromptGuidance.trim().length === 0) {
- return false
- }
- // nosemgrep: prefer-codegen-api
- await api.create(
- `api/environments/${teamId}/llm_analytics/evaluation_reports/`,
- buildReportCreatePayload(draft, evaluationId, targets)
+
+ await llmAnalyticsEvaluationReportsCreate(
+ teamId.toString(),
+ buildReportCreatePayload(draft, evaluationId, targets) as EvaluationReportCreateBody
)
return true
}
@@ -196,9 +249,8 @@ export const evaluationReportLogic = kea<evaluationReportLogicType>([
actions({
setDraftEnabled: (enabled: boolean) => ({ enabled }),
setDraftFrequency: (frequency: EvaluationReportFrequency) => ({ frequency }),
- setDraftRrule: (rrule: string) => ({ rrule }),
- setDraftStartsAt: (startsAt: string | null) => ({ startsAt }),
- setDraftTimezoneName: (timezoneName: string) => ({ timezoneName }),
+ setDraftScheduleCadence: (cadence: ReportScheduleCadence) => ({ cadence }),
+ toggleDraftScheduleWeekday: (weekday: ReportScheduleWeekday) => ({ weekday }),
setDraftEmailValue: (emailValue: string) => ({ emailValue }),
setDraftSlackIntegrationId: (integrationId: number | null) => ({ integrationId }),
setDraftSlackChannelValue: (channelValue: string) => ({ channelValue }),
@@ -220,16 +272,25 @@ export const evaluationReportLogic = kea<evaluationReportLogicType>([
{
setDraftEnabled: (state, { enabled }) => ({ ...state, enabled }),
setDraftFrequency: (state, { frequency }) => {
- // Seed a default rrule when switching into scheduled mode for the first time so
- // the Save button can commit without forcing the user to fill the field manually.
- const rrule = frequency === 'scheduled' && !state.rrule ? DEFAULT_RRULE : state.rrule
- const startsAt =
- frequency === 'scheduled' && !state.startsAt ? new Date().toISOString() : state.startsAt
- return { ...state, frequency, rrule, startsAt }
+ return { ...state, frequency }
+ },
+ setDraftScheduleCadence: (state, { cadence }) => ({
+ ...state,
+ scheduleCadence: cadence,
+ }),
+ toggleDraftScheduleWeekday: (state, { weekday }) => {
+ const existing = new Set(state.scheduleWeekdays)
+ if (existing.has(weekday)) {
+ existing.delete(weekday)
+ } else {
+ existing.add(weekday)
+ }
+ const scheduleWeekdays = normalizeScheduleWeekdays([...existing])
+ return {
+ ...state,
+ scheduleWeekdays,
+ }
},
- setDraftRrule: (state, { rrule }) => ({ ...state, rrule }),
- setDraftStartsAt: (state, { startsAt }) => ({ ...state, startsAt }),
- setDraftTimezoneName: (state, { timezoneName }) => ({ ...state, timezoneName }),
setDraftEmailValue: (state, { emailValue }) => ({ ...state, emailValue }),
setDraftSlackIntegrationId: (state, { integrationId }) => ({
...state,
@@ -274,18 +335,13 @@ export const evaluationReportLogic = kea<evaluationReportLogicType>([
if (props.evaluationId === 'new') {
return []
}
- // nosemgrep: prefer-codegen-api
- const response = await api.get(
- `api/environments/${values.currentTeamId}/llm_analytics/evaluation_reports/?evaluation=${props.evaluationId}`
- )
- return response.results || []
+ return loadReportsForEvaluation(requireCurrentTeamId(values.currentTeamId), props.evaluationId)
},
createReport: async (params: {
evaluationId: string
+ enabled: boolean
frequency: EvaluationReportFrequency
rrule?: string
- starts_at?: string | null
- timezone_name?: string
delivery_targets: EvaluationReportDeliveryTarget[]
report_prompt_guidance?: string
trigger_threshold?: number | null
@@ -296,12 +352,10 @@ export const evaluationReportLogic = kea<evaluationReportLogicType>([
frequency: params.frequency,
delivery_targets: params.delivery_targets,
report_prompt_guidance: params.report_prompt_guidance ?? '',
- enabled: true,
+ enabled: params.enabled,
}
if (params.frequency === 'scheduled') {
body.rrule = params.rrule ?? ''
- body.starts_at = params.starts_at ?? null
- body.timezone_name = params.timezone_name ?? DEFAULT_TIMEZONE
}
if (params.frequency === 'every_n' && params.trigger_threshold != null) {
body.trigger_threshold = params.trigger_threshold
@@ -309,28 +363,24 @@ export const evaluationReportLogic = kea<evaluationReportLogicType>([
if (params.frequency === 'every_n' && params.cooldown_minutes != null) {
body.cooldown_minutes = params.cooldown_minutes
}
- // nosemgrep: prefer-codegen-api
- const report = await api.create(
- `api/environments/${values.currentTeamId}/llm_analytics/evaluation_reports/`,
- body
+ const teamId = requireCurrentTeamId(values.currentTeamId)
+ const report = await llmAnalyticsEvaluationReportsCreate(
+ teamId.toString(),
+ body as EvaluationReportCreateBody
)
- return [...values.reports, report]
+ return [
+ ...values.reports.filter((existing) => existing.id !== report.id),
+ report as EvaluationReport,
+ ]
},
updateReport: async ({ reportId, data }: { reportId: string; data: Partial<EvaluationReport> }) => {
- // nosemgrep: prefer-codegen-api
- const updated = await api.update(
- `api/environments/${values.currentTeamId}/llm_analytics/evaluation_reports/${reportId}/`,
- data
- )
- return values.reports.map((r) => (r.id === reportId ? updated : r))
- },
- deleteReport: async (reportId: string) => {
- // nosemgrep: prefer-codegen-api
- await api.update(
- `api/environments/${values.currentTeamId}/llm_analytics/evaluation_reports/${reportId}/`,
- { deleted: true }
+ const teamId = requireCurrentTeamId(values.currentTeamId)
+ const updated = await llmAnalyticsEvaluationReportsPartialUpdate(
+ teamId.toString(),
+ reportId,
+ data as EvaluationReportPatchBody
)
- return values.reports.filter((r) => r.id !== reportId)
+ return values.reports.map((r) => (r.id === reportId ? (updated as EvaluationReport) : r))
},
},
],
@@ -338,13 +388,11 @@ export const evaluationReportLogic = kea<evaluationReportLogicType>([
[] as EvaluationReportRun[],
{
loadReportRuns: async (reportId: string) => {
- // nosemgrep: prefer-codegen-api
- const response = await api.get(
- `api/environments/${values.currentTeamId}/llm_analytics/evaluation_reports/${reportId}/runs/`
- )
+ const teamId = requireCurrentTeamId(values.currentTeamId)
+ const response = await llmAnalyticsEvaluationReportsRunsList(teamId.toString(), reportId)
// The runs endpoint is paginated (DRF envelope); unwrap results so the
// reducer gets an array rather than the {count, next, previous, results} object.
- return response?.results || []
+ return (response?.results || []) as unknown as EvaluationReportRun[]
},
},
],
@@ -352,10 +400,8 @@ export const evaluationReportLogic = kea<evaluationReportLogicType>([
null as null,
{
generateReport: async (reportId: string) => {
- // nosemgrep: prefer-codegen-api
- await api.create(
- `api/environments/${values.currentTeamId}/llm_analytics/evaluation_reports/${reportId}/generate/`
- )
+ const teamId = requireCurrentTeamId(values.currentTeamId)
+ await llmAnalyticsEvaluationReportsGenerateCreate(teamId.toString(), reportId)
return null
},
},
@@ -367,7 +413,7 @@ export const evaluationReportLogic = kea<evaluationReportLogicType>([
activeReport: [
(s) => [s.reports],
(reports): EvaluationReport | null => {
- return reports.find((r: EvaluationReport) => r.enabled && !r.deleted) || null
+ return reports.find((r: EvaluationReport) => !r.deleted) || null
},
],
isConfigDirty: [
@@ -375,15 +421,22 @@ export const evaluationReportLogic = kea<evaluationReportLogicType>([
(activeReport, draft): boolean => {
if (!activeReport) {
// No report yet: draft is "dirty" if it has any savable content.
- return buildDeliveryTargets(draft).length > 0 || draft.reportPromptGuidance.trim().length > 0
+ return (
+ !draft.enabled ||
+ draft.frequency !== 'every_n' ||
+ buildDeliveryTargets(draft).length > 0 ||
+ draft.reportPromptGuidance.trim().length > 0 ||
+ draft.triggerThreshold !== TRIGGER_THRESHOLD_DEFAULT ||
+ draft.cooldownHours !== COOLDOWN_HOURS_DEFAULT
+ )
}
const baseline = draftFromReport(activeReport)
const scheduleDirty =
draft.frequency === 'scheduled' &&
- (baseline.rrule !== draft.rrule ||
- baseline.startsAt !== draft.startsAt ||
- baseline.timezoneName !== draft.timezoneName)
+ rruleFromSchedule(baseline.scheduleCadence, baseline.scheduleWeekdays) !==
+ rruleFromSchedule(draft.scheduleCadence, draft.scheduleWeekdays)
return (
+ baseline.enabled !== draft.enabled ||
baseline.frequency !== draft.frequency ||
baseline.emailValue !== draft.emailValue.trim() ||
baseline.slackIntegrationId !== draft.slackIntegrationId ||
@@ -399,9 +452,9 @@ export const evaluationReportLogic = kea<evaluationReportLogicType>([
listeners(({ actions, values, props }) => ({
loadReportsSuccess: ({ reports }) => {
- // Auto-load the run history for the active report so the Reports tab knows
+ // Auto-load the run history for the saved report so the Reports tab knows
// whether to render itself and can show data immediately.
- const active = reports.find((r: EvaluationReport) => r.enabled && !r.deleted)
+ const active = reports.find((r: EvaluationReport) => !r.deleted)
if (active) {
actions.loadReportRuns(active.id)
// Seed the draft so the config form reflects the saved report instead of defaults.
@@ -431,10 +484,9 @@ export const evaluationReportLogic = kea<evaluationReportLogicType>([
} else {
actions.createReport({
evaluationId: props.evaluationId,
+ enabled: configDraft.enabled,
frequency: configDraft.frequency,
- rrule: configDraft.rrule,
- starts_at: configDraft.startsAt,
- timezone_name: configDraft.timezoneName,
+ rrule: rruleFromSchedule(configDraft.scheduleCadence, configDraft.scheduleWeekdays),
delivery_targets: targets,
report_prompt_guidance: configDraft.reportPromptGuidance,
trigger_threshold: configDraft.frequency === 'every_n' ? configDraft.triggerThreshold : null,
diff --git a/products/ai_observability/frontend/generated/api.schemas.ts b/products/ai_observability/frontend/generated/api.schemas.ts
index d35ce8d96a5f..8e1bf94af37d 100644
--- a/products/ai_observability/frontend/generated/api.schemas.ts
+++ b/products/ai_observability/frontend/generated/api.schemas.ts
@@ -1000,23 +1000,20 @@ export interface EvaluationReportApi {
readonly id: string
/** UUID of the evaluation this report config belongs to. */
evaluation: string
- /** How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.
+ /** How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.
*
* * `scheduled` - Scheduled
* * `every_n` - Every N */
frequency?: EvaluationReportFrequencyEnumApi
- /** RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise. */
+ /** RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise. */
rrule?: string
/**
- * Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise.
+ * Read-only anchor datetime used to expand scheduled reports. The server sets this automatically when a report is switched to scheduled mode.
* @nullable
*/
- starts_at?: string | null
- /**
- * IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America/New_York'). Defaults to 'UTC'.
- * @maxLength 64
- */
- timezone_name?: string
+ readonly starts_at: string | null
+ /** Read-only timezone used for scheduled reports. Evaluation reports use UTC. */
+ readonly timezone_name: string
/** @nullable */
readonly next_delivery_date: string | null
/** List of delivery targets. Each entry is either {type: 'email', value: '[email protected]'} or {type: 'slack', integration_id: <int>, channel: '<channel>'}. Slack integration_id must belong to this team. */
@@ -1029,15 +1026,15 @@ export interface EvaluationReportApi {
max_sample_size?: number
/** Whether report delivery is active. Disabled configs do not fire. */
enabled?: boolean
- /** Set to true to soft-delete this report config. */
- deleted?: boolean
+ /** Read-only. Report configs are soft-deleted only when their evaluation is deleted. Use enabled=false to stop deliveries. */
+ readonly deleted: boolean
/** @nullable */
readonly last_delivered_at: string | null
/** Optional custom instructions appended to the AI report prompt to steer focus, scope, or section choices without modifying the base prompt. */
report_prompt_guidance?: string
/**
- * Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'.
- * @minimum 10
+ * Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'.
+ * @minimum 100
* @maximum 10000
* @nullable
*/
@@ -1068,27 +1065,84 @@ export interface PaginatedEvaluationReportListApi {
results: EvaluationReportApi[]
}
-export interface PatchedEvaluationReportApi {
- readonly id?: string
+export interface EvaluationReportUpdateApi {
+ readonly id: string
/** UUID of the evaluation this report config belongs to. */
- evaluation?: string
- /** How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.
+ readonly evaluation: string
+ /** How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.
*
* * `scheduled` - Scheduled
* * `every_n` - Every N */
frequency?: EvaluationReportFrequencyEnumApi
- /** RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise. */
+ /** RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise. */
rrule?: string
/**
- * Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise.
+ * Read-only anchor datetime used to expand scheduled reports. The server sets this automatically when a report is switched to scheduled mode.
* @nullable
*/
- starts_at?: string | null
+ readonly starts_at: string | null
+ /** Read-only timezone used for scheduled reports. Evaluation reports use UTC. */
+ readonly timezone_name: string
+ /** @nullable */
+ readonly next_delivery_date: string | null
+ /** List of delivery targets. Each entry is either {type: 'email', value: '[email protected]'} or {type: 'slack', integration_id: <int>, channel: '<channel>'}. Slack integration_id must belong to this team. */
+ delivery_targets?: unknown
/**
- * IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America/New_York'). Defaults to 'UTC'.
- * @maxLength 64
+ * Maximum number of evaluation runs included in each report. Defaults to 200.
+ * @minimum -2147483648
+ * @maximum 2147483647
+ */
+ max_sample_size?: number
+ /** Whether report delivery is active. Disabled configs do not fire. */
+ enabled?: boolean
+ /** Read-only. Report configs are soft-deleted only when their evaluation is deleted. Use enabled=false to stop deliveries. */
+ readonly deleted: boolean
+ /** @nullable */
+ readonly last_delivered_at: string | null
+ /** Optional custom instructions appended to the AI report prompt to steer focus, scope, or section choices without modifying the base prompt. */
+ report_prompt_guidance?: string
+ /**
+ * Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'.
+ * @minimum 100
+ * @maximum 10000
+ * @nullable
+ */
+ trigger_threshold?: number | null
+ /**
+ * Minimum minutes between count-triggered reports to prevent spam (every_n mode only). Min 60, max 1440 (24 hours). Defaults to 60.
+ * @minimum 60
+ * @maximum 1440
+ */
+ cooldown_minutes?: number
+ /**
+ * Maximum count-triggered report runs per calendar day (UTC). Min 1, max 24 (one per cooldown window). Defaults to 10.
+ * @minimum 1
+ * @maximum 24
*/
- timezone_name?: string
+ daily_run_cap?: number
+ /** @nullable */
+ readonly created_by: number | null
+ readonly created_at: string
+}
+
+export interface PatchedEvaluationReportUpdateApi {
+ readonly id?: string
+ /** UUID of the evaluation this report config belongs to. */
+ readonly evaluation?: string
+ /** How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.
+ *
+ * * `scheduled` - Scheduled
+ * * `every_n` - Every N */
+ frequency?: EvaluationReportFrequencyEnumApi
+ /** RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise. */
+ rrule?: string
+ /**
+ * Read-only anchor datetime used to expand scheduled reports. The server sets this automatically when a report is switched to scheduled mode.
+ * @nullable
+ */
+ readonly starts_at?: string | null
+ /** Read-only timezone used for scheduled reports. Evaluation reports use UTC. */
+ readonly timezone_name?: string
/** @nullable */
readonly next_delivery_date?: string | null
/** List of delivery targets. Each entry is either {type: 'email', value: '[email protected]'} or {type: 'slack', integration_id: <int>, channel: '<channel>'}. Slack integration_id must belong to this team. */
@@ -1101,15 +1155,15 @@ export interface PatchedEvaluationReportApi {
max_sample_size?: number
/** Whether report delivery is active. Disabled configs do not fire. */
enabled?: boolean
- /** Set to true to soft-delete this report config. */
- deleted?: boolean
+ /** Read-only. Report configs are soft-deleted only when their evaluation is deleted. Use enabled=false to stop deliveries. */
+ readonly deleted?: boolean
/** @nullable */
readonly last_delivered_at?: string | null
/** Optional custom instructions appended to the AI report prompt to steer focus, scope, or section choices without modifying the base prompt. */
report_prompt_guidance?: string
/**
- * Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'.
- * @minimum 10
+ * Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'.
+ * @minimum 100
* @maximum 10000
* @nullable
*/
@@ -2473,6 +2527,10 @@ export type LlmAnalyticsClusteringJobsListParams = {
}
export type LlmAnalyticsEvaluationReportsListParams = {
+ /**
+ * Only return report configs for this evaluation UUID.
+ */
+ evaluation?: string
/**
* Number of results to return per page.
*/
diff --git a/products/ai_observability/frontend/generated/api.ts b/products/ai_observability/frontend/generated/api.ts
index b39caeca2943..0fb34a81abf7 100644
--- a/products/ai_observability/frontend/generated/api.ts
+++ b/products/ai_observability/frontend/generated/api.ts
@@ -23,6 +23,7 @@ import type {
EvaluationConfigApi,
EvaluationConfigSetActiveKeyRequestApi,
EvaluationReportApi,
+ EvaluationReportUpdateApi,
EvaluationRunRequestApi,
EvaluationRunsCreate200,
EvaluationSummaryRequestApi,
@@ -71,7 +72,7 @@ import type {
PatchedDatasetApi,
PatchedDatasetItemApi,
PatchedEvaluationApi,
- PatchedEvaluationReportApi,
+ PatchedEvaluationReportUpdateApi,
PatchedLLMPromptPublishApi,
PatchedLLMProviderKeyApi,
PatchedParserRecipeApi,
@@ -826,14 +827,14 @@ export const getLlmAnalyticsEvaluationReportsUpdateUrl = (projectId: string, id:
export const llmAnalyticsEvaluationReportsUpdate = async (
projectId: string,
id: string,
- evaluationReportApi: NonReadonly<EvaluationReportApi>,
+ evaluationReportUpdateApi?: NonReadonly<EvaluationReportUpdateApi>,
options?: RequestInit
-): Promise<EvaluationReportApi> => {
- return apiMutator<EvaluationReportApi>(getLlmAnalyticsEvaluationReportsUpdateUrl(projectId, id), {
+): Promise<EvaluationReportUpdateApi> => {
+ return apiMutator<EvaluationReportUpdateApi>(getLlmAnalyticsEvaluationReportsUpdateUrl(projectId, id), {
...options,
method: 'PUT',
headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(evaluationReportApi),
+ body: JSON.stringify(evaluationReportUpdateApi),
})
}
@@ -847,14 +848,14 @@ export const getLlmAnalyticsEvaluationReportsPartialUpdateUrl = (projectId: stri
export const llmAnalyticsEvaluationReportsPartialUpdate = async (
projectId: string,
id: string,
- patchedEvaluationReportApi?: NonReadonly<PatchedEvaluationReportApi>,
+ patchedEvaluationReportUpdateApi?: NonReadonly<PatchedEvaluationReportUpdateApi>,
options?: RequestInit
-): Promise<EvaluationReportApi> => {
- return apiMutator<EvaluationReportApi>(getLlmAnalyticsEvaluationReportsPartialUpdateUrl(projectId, id), {
+): Promise<EvaluationReportUpdateApi> => {
+ return apiMutator<EvaluationReportUpdateApi>(getLlmAnalyticsEvaluationReportsPartialUpdateUrl(projectId, id), {
...options,
method: 'PATCH',
headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(patchedEvaluationReportApi),
+ body: JSON.stringify(patchedEvaluationReportUpdateApi),
})
}
@@ -863,7 +864,7 @@ export const getLlmAnalyticsEvaluationReportsDestroyUrl = (projectId: string, id
}
/**
- * Hard delete of this model is not allowed. Use a patch API call to set "deleted" to true
+ * Evaluation report configs are deleted only when their evaluation is deleted. Use PATCH enabled=false to stop delivery.
*/
export const llmAnalyticsEvaluationReportsDestroy = async (
projectId: string,
diff --git a/products/ai_observability/frontend/generated/api.zod.ts b/products/ai_observability/frontend/generated/api.zod.ts
index 52d03285c87e..2f34993861a3 100644
--- a/products/ai_observability/frontend/generated/api.zod.ts
+++ b/products/ai_observability/frontend/generated/api.zod.ts
@@ -788,12 +788,10 @@ export const LlmAnalyticsEvaluationConfigSetActiveKeyCreateBody = /* @__PURE__ *
/**
* CRUD for evaluation report configurations + report run history.
*/
-export const llmAnalyticsEvaluationReportsCreateBodyTimezoneNameMax = 64
-
export const llmAnalyticsEvaluationReportsCreateBodyMaxSampleSizeMin = -2147483648
export const llmAnalyticsEvaluationReportsCreateBodyMaxSampleSizeMax = 2147483647
-export const llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMin = 10
+export const llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMin = 100
export const llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMax = 10000
export const llmAnalyticsEvaluationReportsCreateBodyCooldownMinutesMin = 60
@@ -808,26 +806,13 @@ export const LlmAnalyticsEvaluationReportsCreateBody = /* @__PURE__ */ zod.objec
.describe('\* `scheduled` - Scheduled\n\* `every_n` - Every N')
.optional()
.describe(
- "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.\n\n\* `scheduled` - Scheduled\n\* `every_n` - Every N"
+ "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.\n\n\* `scheduled` - Scheduled\n\* `every_n` - Every N"
),
rrule: zod
.string()
.optional()
.describe(
- "RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise."
- ),
- starts_at: zod.iso
- .datetime({ offset: true })
- .nullish()
- .describe(
- "Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise."
- ),
- timezone_name: zod
- .string()
- .max(llmAnalyticsEvaluationReportsCreateBodyTimezoneNameMax)
- .optional()
- .describe(
- "IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America\/New_York'). Defaults to 'UTC'."
+ "RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise."
),
delivery_targets: zod
.unknown()
@@ -842,7 +827,6 @@ export const LlmAnalyticsEvaluationReportsCreateBody = /* @__PURE__ */ zod.objec
.optional()
.describe('Maximum number of evaluation runs included in each report. Defaults to 200.'),
enabled: zod.boolean().optional().describe('Whether report delivery is active. Disabled configs do not fire.'),
- deleted: zod.boolean().optional().describe('Set to true to soft-delete this report config.'),
report_prompt_guidance: zod
.string()
.optional()
@@ -855,7 +839,7 @@ export const LlmAnalyticsEvaluationReportsCreateBody = /* @__PURE__ */ zod.objec
.max(llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMax)
.nullish()
.describe(
- "Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'."
+ "Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'."
),
cooldown_minutes: zod
.number()
@@ -878,12 +862,10 @@ export const LlmAnalyticsEvaluationReportsCreateBody = /* @__PURE__ */ zod.objec
/**
* CRUD for evaluation report configurations + report run history.
*/
-export const llmAnalyticsEvaluationReportsUpdateBodyTimezoneNameMax = 64
-
export const llmAnalyticsEvaluationReportsUpdateBodyMaxSampleSizeMin = -2147483648
export const llmAnalyticsEvaluationReportsUpdateBodyMaxSampleSizeMax = 2147483647
-export const llmAnalyticsEvaluationReportsUpdateBodyTriggerThresholdMin = 10
+export const llmAnalyticsEvaluationReportsUpdateBodyTriggerThresholdMin = 100
export const llmAnalyticsEvaluationReportsUpdateBodyTriggerThresholdMax = 10000
export const llmAnalyticsEvaluationReportsUpdateBodyCooldownMinutesMin = 60
@@ -892,32 +874,18 @@ export const llmAnalyticsEvaluationReportsUpdateBodyCooldownMinutesMax = 1440
export const llmAnalyticsEvaluationReportsUpdateBodyDailyRunCapMax = 24
export const LlmAnalyticsEvaluationReportsUpdateBody = /* @__PURE__ */ zod.object({
- evaluation: zod.uuid().describe('UUID of the evaluation this report config belongs to.'),
frequency: zod
.enum(['scheduled', 'every_n'])
.describe('\* `scheduled` - Scheduled\n\* `every_n` - Every N')
.optional()
.describe(
- "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.\n\n\* `scheduled` - Scheduled\n\* `every_n` - Every N"
+ "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.\n\n\* `scheduled` - Scheduled\n\* `every_n` - Every N"
),
rrule: zod
.string()
.optional()
.describe(
- "RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise."
- ),
- starts_at: zod.iso
- .datetime({ offset: true })
- .nullish()
- .describe(
- "Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise."
- ),
- timezone_name: zod
- .string()
- .max(llmAnalyticsEvaluationReportsUpdateBodyTimezoneNameMax)
- .optional()
- .describe(
- "IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America\/New_York'). Defaults to 'UTC'."
+ "RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise."
),
delivery_targets: zod
.unknown()
@@ -932,7 +900,6 @@ export const LlmAnalyticsEvaluationReportsUpdateBody = /* @__PURE__ */ zod.objec
.optional()
.describe('Maximum number of evaluation runs included in each report. Defaults to 200.'),
enabled: zod.boolean().optional().describe('Whether report delivery is active. Disabled configs do not fire.'),
- deleted: zod.boolean().optional().describe('Set to true to soft-delete this report config.'),
report_prompt_guidance: zod
.string()
.optional()
@@ -945,7 +912,7 @@ export const LlmAnalyticsEvaluationReportsUpdateBody = /* @__PURE__ */ zod.objec
.max(llmAnalyticsEvaluationReportsUpdateBodyTriggerThresholdMax)
.nullish()
.describe(
- "Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'."
+ "Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'."
),
cooldown_minutes: zod
.number()
@@ -968,12 +935,10 @@ export const LlmAnalyticsEvaluationReportsUpdateBody = /* @__PURE__ */ zod.objec
/**
* CRUD for evaluation report configurations + report run history.
*/
-export const llmAnalyticsEvaluationReportsPartialUpdateBodyTimezoneNameMax = 64
-
export const llmAnalyticsEvaluationReportsPartialUpdateBodyMaxSampleSizeMin = -2147483648
export const llmAnalyticsEvaluationReportsPartialUpdateBodyMaxSampleSizeMax = 2147483647
-export const llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMin = 10
+export const llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMin = 100
export const llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMax = 10000
export const llmAnalyticsEvaluationReportsPartialUpdateBodyCooldownMinutesMin = 60
@@ -982,32 +947,18 @@ export const llmAnalyticsEvaluationReportsPartialUpdateBodyCooldownMinutesMax =
export const llmAnalyticsEvaluationReportsPartialUpdateBodyDailyRunCapMax = 24
export const LlmAnalyticsEvaluationReportsPartialUpdateBody = /* @__PURE__ */ zod.object({
- evaluation: zod.uuid().optional().describe('UUID of the evaluation this report config belongs to.'),
frequency: zod
.enum(['scheduled', 'every_n'])
.describe('\* `scheduled` - Scheduled\n\* `every_n` - Every N')
.optional()
.describe(
- "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.\n\n\* `scheduled` - Scheduled\n\* `every_n` - Every N"
+ "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.\n\n\* `scheduled` - Scheduled\n\* `every_n` - Every N"
),
rrule: zod
.string()
.optional()
.describe(
- "RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise."
- ),
- starts_at: zod.iso
- .datetime({ offset: true })
- .nullish()
- .describe(
- "Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise."
- ),
- timezone_name: zod
- .string()
- .max(llmAnalyticsEvaluationReportsPartialUpdateBodyTimezoneNameMax)
- .optional()
- .describe(
- "IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America\/New_York'). Defaults to 'UTC'."
+ "RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise."
),
delivery_targets: zod
.unknown()
@@ -1022,7 +973,6 @@ export const LlmAnalyticsEvaluationReportsPartialUpdateBody = /* @__PURE__ */ zo
.optional()
.describe('Maximum number of evaluation runs included in each report. Defaults to 200.'),
enabled: zod.boolean().optional().describe('Whether report delivery is active. Disabled configs do not fire.'),
- deleted: zod.boolean().optional().describe('Set to true to soft-delete this report config.'),
report_prompt_guidance: zod
.string()
.optional()
@@ -1035,7 +985,7 @@ export const LlmAnalyticsEvaluationReportsPartialUpdateBody = /* @__PURE__ */ zo
.max(llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMax)
.nullish()
.describe(
- "Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'."
+ "Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'."
),
cooldown_minutes: zod
.number()
diff --git a/products/ai_observability/mcp/tools.yaml b/products/ai_observability/mcp/tools.yaml
index e6906126f758..9d454e9d064a 100644
--- a/products/ai_observability/mcp/tools.yaml
+++ b/products/ai_observability/mcp/tools.yaml
@@ -282,7 +282,7 @@ tools:
annotations:
readOnly: false
destructive: false
- idempotent: false
+ idempotent: true
title: Create evaluation report config
description: |
Create an evaluation report configuration. Reports summarize recent evaluation runs (using AI)
@@ -291,12 +291,11 @@ tools:
- 'every_n' (count-based): a report fires once `trigger_threshold` new evaluation results have
accumulated, but no more often than `cooldown_minutes` apart and capped by `daily_run_cap` per
- UTC day. `trigger_threshold` is required in this mode (10–10000); `cooldown_minutes` (60–1440)
+ UTC day. `trigger_threshold` is required in this mode (100–10000); `cooldown_minutes` (60–1440)
and `daily_run_cap` are optional.
- - 'scheduled' (time-based): reports fire on the cadence defined by `rrule` (RFC 5545, e.g.
- 'FREQ=WEEKLY;BYDAY=MO') anchored at `starts_at` and expanded in `timezone_name` so local clock
- times survive DST transitions. `rrule` and `starts_at` are required in this mode;
- `timezone_name` defaults to 'UTC'.
+ - 'scheduled' (time-based): reports fire on the daily or weekly cadence defined by `rrule`. Use
+ 'FREQ=DAILY' for daily reports or 'FREQ=WEEKLY;BYDAY=MO,FR' for weekly reports on selected days.
+ The server sets the schedule anchor and timezone automatically.
`delivery_targets` is a list of {type: 'email', value: '<addr>'} or {type: 'slack',
integration_id: <int>, channel: '<channel>'} entries. Slack integrations must belong to the
@@ -310,26 +309,11 @@ tools:
- cooldown_minutes
- daily_run_cap
- rrule
- - starts_at
- - timezone_name
- max_sample_size
- report_prompt_guidance
llma-evaluation-report-delete:
operation: llm_analytics_evaluation_reports_destroy
- enabled: true
- scopes:
- - llm_analytics:write
- annotations:
- readOnly: false
- destructive: true
- idempotent: true
- title: Delete evaluation report config
- description: >
- Soft-delete an evaluation report configuration. The report stops firing and is hidden from list views;
- historical report runs are preserved. Equivalent to calling llma-evaluation-report-update with deleted=true
- — that update path is the canonical way to soft-delete and is the only option when you also want to change
- other fields in the same call.
- soft_delete: true
+ enabled: false
llma-evaluation-report-generate:
operation: llm_analytics_evaluation_reports_generate_create
enabled: true
@@ -399,8 +383,9 @@ tools:
description: >
Partially update an evaluation report configuration. Toggle enabled/disabled, update delivery targets (email
or Slack), or switch frequency between 'every_n' and 'scheduled'. For 'every_n' mode set trigger_threshold
- (10–10000) and optionally cooldown_minutes (60–1440); for 'scheduled' mode set rrule and starts_at. Set
- deleted=true to soft-delete the config.
+ (100–10000) and optionally cooldown_minutes (60–1440); for 'scheduled' mode set rrule to a daily or weekly
+ cadence such as 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Disable delivery with enabled=false; report
+ configs are deleted only when their evaluation is deleted.
llma-evaluation-report-update-full:
operation: llm_analytics_evaluation_reports_update
enabled: false
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index bd2de4fa4670..a6f361cfccf4 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -4680,7 +4680,7 @@
}
},
"llma-evaluation-report-create": {
- "description": "Create an evaluation report configuration. Reports summarize recent evaluation runs (using AI)\nand are delivered to email or Slack targets. `frequency` selects the trigger mode and defaults\nto 'every_n' if omitted:\n\n- 'every_n' (count-based): a report fires once `trigger_threshold` new evaluation results have\naccumulated, but no more often than `cooldown_minutes` apart and capped by `daily_run_cap` per\nUTC day. `trigger_threshold` is required in this mode (10–10000); `cooldown_minutes` (60–1440)\nand `daily_run_cap` are optional.\n- 'scheduled' (time-based): reports fire on the cadence defined by `rrule` (RFC 5545, e.g.\n'FREQ=WEEKLY;BYDAY=MO') anchored at `starts_at` and expanded in `timezone_name` so local clock\ntimes survive DST transitions. `rrule` and `starts_at` are required in this mode;\n`timezone_name` defaults to 'UTC'.\n\n`delivery_targets` is a list of {type: 'email', value: '<addr>'} or {type: 'slack',\nintegration_id: <int>, channel: '<channel>'} entries. Slack integrations must belong to the\nsame team. Use `report_prompt_guidance` to steer the AI report's focus.",
+ "description": "Create an evaluation report configuration. Reports summarize recent evaluation runs (using AI)\nand are delivered to email or Slack targets. `frequency` selects the trigger mode and defaults\nto 'every_n' if omitted:\n\n- 'every_n' (count-based): a report fires once `trigger_threshold` new evaluation results have\naccumulated, but no more often than `cooldown_minutes` apart and capped by `daily_run_cap` per\nUTC day. `trigger_threshold` is required in this mode (100–10000); `cooldown_minutes` (60–1440)\nand `daily_run_cap` are optional.\n- 'scheduled' (time-based): reports fire on the daily or weekly cadence defined by `rrule`. Use\n'FREQ=DAILY' for daily reports or 'FREQ=WEEKLY;BYDAY=MO,FR' for weekly reports on selected days.\nThe server sets the schedule anchor and timezone automatically.\n\n`delivery_targets` is a list of {type: 'email', value: '<addr>'} or {type: 'slack',\nintegration_id: <int>, channel: '<channel>'} entries. Slack integrations must belong to the\nsame team. Use `report_prompt_guidance` to steer the AI report's focus.",
"category": "AI observability",
"feature": "llm_analytics",
"summary": "Create evaluation report config",
@@ -4688,20 +4688,6 @@
"required_scopes": ["llm_analytics:write"],
"annotations": {
"destructiveHint": false,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- }
- },
- "llma-evaluation-report-delete": {
- "description": "Soft-delete an evaluation report configuration. The report stops firing and is hidden from list views; historical report runs are preserved. Equivalent to calling llma-evaluation-report-update with deleted=true — that update path is the canonical way to soft-delete and is the only option when you also want to change other fields in the same call.",
- "category": "AI observability",
- "feature": "llm_analytics",
- "summary": "Delete evaluation report config",
- "title": "Delete evaluation report config",
- "required_scopes": ["llm_analytics:write"],
- "annotations": {
- "destructiveHint": true,
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": false
@@ -4764,7 +4750,7 @@
}
},
"llma-evaluation-report-update": {
- "description": "Partially update an evaluation report configuration. Toggle enabled/disabled, update delivery targets (email or Slack), or switch frequency between 'every_n' and 'scheduled'. For 'every_n' mode set trigger_threshold (10–10000) and optionally cooldown_minutes (60–1440); for 'scheduled' mode set rrule and starts_at. Set deleted=true to soft-delete the config.",
+ "description": "Partially update an evaluation report configuration. Toggle enabled/disabled, update delivery targets (email or Slack), or switch frequency between 'every_n' and 'scheduled'. For 'every_n' mode set trigger_threshold (100–10000) and optionally cooldown_minutes (60–1440); for 'scheduled' mode set rrule to a daily or weekly cadence such as 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Disable delivery with enabled=false; report configs are deleted only when their evaluation is deleted.",
"category": "AI observability",
"feature": "llm_analytics",
"summary": "Update evaluation report config",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index cba276fd01c9..e3af3e30366b 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -4976,7 +4976,7 @@
}
},
"llma-evaluation-report-create": {
- "description": "Create an evaluation report configuration. Reports summarize recent evaluation runs (using AI)\nand are delivered to email or Slack targets. `frequency` selects the trigger mode and defaults\nto 'every_n' if omitted:\n\n- 'every_n' (count-based): a report fires once `trigger_threshold` new evaluation results have\naccumulated, but no more often than `cooldown_minutes` apart and capped by `daily_run_cap` per\nUTC day. `trigger_threshold` is required in this mode (10–10000); `cooldown_minutes` (60–1440)\nand `daily_run_cap` are optional.\n- 'scheduled' (time-based): reports fire on the cadence defined by `rrule` (RFC 5545, e.g.\n'FREQ=WEEKLY;BYDAY=MO') anchored at `starts_at` and expanded in `timezone_name` so local clock\ntimes survive DST transitions. `rrule` and `starts_at` are required in this mode;\n`timezone_name` defaults to 'UTC'.\n\n`delivery_targets` is a list of {type: 'email', value: '<addr>'} or {type: 'slack',\nintegration_id: <int>, channel: '<channel>'} entries. Slack integrations must belong to the\nsame team. Use `report_prompt_guidance` to steer the AI report's focus.",
+ "description": "Create an evaluation report configuration. Reports summarize recent evaluation runs (using AI)\nand are delivered to email or Slack targets. `frequency` selects the trigger mode and defaults\nto 'every_n' if omitted:\n\n- 'every_n' (count-based): a report fires once `trigger_threshold` new evaluation results have\naccumulated, but no more often than `cooldown_minutes` apart and capped by `daily_run_cap` per\nUTC day. `trigger_threshold` is required in this mode (100–10000); `cooldown_minutes` (60–1440)\nand `daily_run_cap` are optional.\n- 'scheduled' (time-based): reports fire on the daily or weekly cadence defined by `rrule`. Use\n'FREQ=DAILY' for daily reports or 'FREQ=WEEKLY;BYDAY=MO,FR' for weekly reports on selected days.\nThe server sets the schedule anchor and timezone automatically.\n\n`delivery_targets` is a list of {type: 'email', value: '<addr>'} or {type: 'slack',\nintegration_id: <int>, channel: '<channel>'} entries. Slack integrations must belong to the\nsame team. Use `report_prompt_guidance` to steer the AI report's focus.",
"category": "AI observability",
"feature": "llm_analytics",
"summary": "Create evaluation report config",
@@ -4984,20 +4984,6 @@
"required_scopes": ["llm_analytics:write"],
"annotations": {
"destructiveHint": false,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- }
- },
- "llma-evaluation-report-delete": {
- "description": "Soft-delete an evaluation report configuration. The report stops firing and is hidden from list views; historical report runs are preserved. Equivalent to calling llma-evaluation-report-update with deleted=true — that update path is the canonical way to soft-delete and is the only option when you also want to change other fields in the same call.",
- "category": "AI observability",
- "feature": "llm_analytics",
- "summary": "Delete evaluation report config",
- "title": "Delete evaluation report config",
- "required_scopes": ["llm_analytics:write"],
- "annotations": {
- "destructiveHint": true,
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": false
@@ -5060,7 +5046,7 @@
}
},
"llma-evaluation-report-update": {
- "description": "Partially update an evaluation report configuration. Toggle enabled/disabled, update delivery targets (email or Slack), or switch frequency between 'every_n' and 'scheduled'. For 'every_n' mode set trigger_threshold (10–10000) and optionally cooldown_minutes (60–1440); for 'scheduled' mode set rrule and starts_at. Set deleted=true to soft-delete the config.",
+ "description": "Partially update an evaluation report configuration. Toggle enabled/disabled, update delivery targets (email or Slack), or switch frequency between 'every_n' and 'scheduled'. For 'every_n' mode set trigger_threshold (100–10000) and optionally cooldown_minutes (60–1440); for 'scheduled' mode set rrule to a daily or weekly cadence such as 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Disable delivery with enabled=false; report configs are deleted only when their evaluation is deleted.",
"category": "AI observability",
"feature": "llm_analytics",
"summary": "Update evaluation report config",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 4c21603f527c..d8460e40ae1b 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -21410,23 +21410,20 @@ export namespace Schemas {
readonly id: string;
/** UUID of the evaluation this report config belongs to. */
evaluation: string;
- /** How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.
+ /** How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.
*
* * `scheduled` - Scheduled
* * `every_n` - Every N */
frequency?: EvaluationReportFrequencyEnum;
- /** RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise. */
+ /** RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise. */
rrule?: string;
/**
- * Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise.
+ * Read-only anchor datetime used to expand scheduled reports. The server sets this automatically when a report is switched to scheduled mode.
* @nullable
*/
- starts_at?: string | null;
- /**
- * IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America/New_York'). Defaults to 'UTC'.
- * @maxLength 64
- */
- timezone_name?: string;
+ readonly starts_at: string | null;
+ /** Read-only timezone used for scheduled reports. Evaluation reports use UTC. */
+ readonly timezone_name: string;
/** @nullable */
readonly next_delivery_date: string | null;
/** List of delivery targets. Each entry is either {type: 'email', value: '[email protected]'} or {type: 'slack', integration_id: <int>, channel: '<channel>'}. Slack integration_id must belong to this team. */
@@ -21439,15 +21436,15 @@ export namespace Schemas {
max_sample_size?: number;
/** Whether report delivery is active. Disabled configs do not fire. */
enabled?: boolean;
- /** Set to true to soft-delete this report config. */
- deleted?: boolean;
+ /** Read-only. Report configs are soft-deleted only when their evaluation is deleted. Use enabled=false to stop deliveries. */
+ readonly deleted: boolean;
/** @nullable */
readonly last_delivered_at: string | null;
/** Optional custom instructions appended to the AI report prompt to steer focus, scope, or section choices without modifying the base prompt. */
report_prompt_guidance?: string;
/**
- * Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'.
- * @minimum 10
+ * Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'.
+ * @minimum 100
* @maximum 10000
* @nullable
*/
@@ -21494,6 +21491,66 @@ export namespace Schemas {
readonly created_at: string;
}
+ export interface EvaluationReportUpdate {
+ readonly id: string;
+ /** UUID of the evaluation this report config belongs to. */
+ readonly evaluation: string;
+ /** How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.
+ *
+ * * `scheduled` - Scheduled
+ * * `every_n` - Every N */
+ frequency?: EvaluationReportFrequencyEnum;
+ /** RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise. */
+ rrule?: string;
+ /**
+ * Read-only anchor datetime used to expand scheduled reports. The server sets this automatically when a report is switched to scheduled mode.
+ * @nullable
+ */
+ readonly starts_at: string | null;
+ /** Read-only timezone used for scheduled reports. Evaluation reports use UTC. */
+ readonly timezone_name: string;
+ /** @nullable */
+ readonly next_delivery_date: string | null;
+ /** List of delivery targets. Each entry is either {type: 'email', value: '[email protected]'} or {type: 'slack', integration_id: <int>, channel: '<channel>'}. Slack integration_id must belong to this team. */
+ delivery_targets?: unknown;
+ /**
+ * Maximum number of evaluation runs included in each report. Defaults to 200.
+ * @minimum -2147483648
+ * @maximum 2147483647
+ */
+ max_sample_size?: number;
+ /** Whether report delivery is active. Disabled configs do not fire. */
+ enabled?: boolean;
+ /** Read-only. Report configs are soft-deleted only when their evaluation is deleted. Use enabled=false to stop deliveries. */
+ readonly deleted: boolean;
+ /** @nullable */
+ readonly last_delivered_at: string | null;
+ /** Optional custom instructions appended to the AI report prompt to steer focus, scope, or section choices without modifying the base prompt. */
+ report_prompt_guidance?: string;
+ /**
+ * Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'.
+ * @minimum 100
+ * @maximum 10000
+ * @nullable
+ */
+ trigger_threshold?: number | null;
+ /**
+ * Minimum minutes between count-triggered reports to prevent spam (every_n mode only). Min 60, max 1440 (24 hours). Defaults to 60.
+ * @minimum 60
+ * @maximum 1440
+ */
+ cooldown_minutes?: number;
+ /**
+ * Maximum count-triggered report runs per calendar day (UTC). Min 1, max 24 (one per cooldown window). Defaults to 10.
+ * @minimum 1
+ * @maximum 24
+ */
+ daily_run_cap?: number;
+ /** @nullable */
+ readonly created_by: number | null;
+ readonly created_at: string;
+ }
+
export interface EvaluationRunRequest {
/** UUID of the evaluation to run. */
evaluation_id: string;
@@ -38942,27 +38999,24 @@ export namespace Schemas {
deleted?: boolean;
}
- export interface PatchedEvaluationReport {
+ export interface PatchedEvaluationReportUpdate {
readonly id?: string;
/** UUID of the evaluation this report config belongs to. */
- evaluation?: string;
- /** How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.
+ readonly evaluation?: string;
+ /** How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.
*
* * `scheduled` - Scheduled
* * `every_n` - Every N */
frequency?: EvaluationReportFrequencyEnum;
- /** RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise. */
+ /** RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise. */
rrule?: string;
/**
- * Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise.
+ * Read-only anchor datetime used to expand scheduled reports. The server sets this automatically when a report is switched to scheduled mode.
* @nullable
*/
- starts_at?: string | null;
- /**
- * IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America/New_York'). Defaults to 'UTC'.
- * @maxLength 64
- */
- timezone_name?: string;
+ readonly starts_at?: string | null;
+ /** Read-only timezone used for scheduled reports. Evaluation reports use UTC. */
+ readonly timezone_name?: string;
/** @nullable */
readonly next_delivery_date?: string | null;
/** List of delivery targets. Each entry is either {type: 'email', value: '[email protected]'} or {type: 'slack', integration_id: <int>, channel: '<channel>'}. Slack integration_id must belong to this team. */
@@ -38975,15 +39029,15 @@ export namespace Schemas {
max_sample_size?: number;
/** Whether report delivery is active. Disabled configs do not fire. */
enabled?: boolean;
- /** Set to true to soft-delete this report config. */
- deleted?: boolean;
+ /** Read-only. Report configs are soft-deleted only when their evaluation is deleted. Use enabled=false to stop deliveries. */
+ readonly deleted?: boolean;
/** @nullable */
readonly last_delivered_at?: string | null;
/** Optional custom instructions appended to the AI report prompt to steer focus, scope, or section choices without modifying the base prompt. */
report_prompt_guidance?: string;
/**
- * Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'.
- * @minimum 10
+ * Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'.
+ * @minimum 100
* @maximum 10000
* @nullable
*/
@@ -60673,6 +60727,10 @@ export namespace Schemas {
};
export type EnvironmentsLlmAnalyticsEvaluationReportsListParams = {
+ /**
+ * Only return report configs for this evaluation UUID.
+ */
+ evaluation?: string;
/**
* Number of results to return per page.
*/
@@ -67848,6 +67906,10 @@ export namespace Schemas {
};
export type LlmAnalyticsEvaluationReportsListParams = {
+ /**
+ * Only return report configs for this evaluation UUID.
+ */
+ evaluation?: string;
/**
* Number of results to return per page.
*/
diff --git a/services/mcp/src/generated/ai_observability/api.ts b/services/mcp/src/generated/ai_observability/api.ts
index aa1c8529cee8..43452244fc9c 100644
--- a/services/mcp/src/generated/ai_observability/api.ts
+++ b/services/mcp/src/generated/ai_observability/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 57 enabled ops
+ * PostHog API - MCP 56 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -654,6 +654,7 @@ export const LlmAnalyticsEvaluationReportsListParams = /* @__PURE__ */ zod.objec
})
export const LlmAnalyticsEvaluationReportsListQueryParams = /* @__PURE__ */ zod.object({
+ evaluation: zod.string().optional().describe('Only return report configs for this evaluation UUID.'),
limit: zod.number().optional().describe('Number of results to return per page.'),
offset: zod.number().optional().describe('The initial index from which to return the results.'),
})
@@ -669,12 +670,10 @@ export const LlmAnalyticsEvaluationReportsCreateParams = /* @__PURE__ */ zod.obj
),
})
-export const llmAnalyticsEvaluationReportsCreateBodyTimezoneNameMax = 64
-
export const llmAnalyticsEvaluationReportsCreateBodyMaxSampleSizeMin = -2147483648
export const llmAnalyticsEvaluationReportsCreateBodyMaxSampleSizeMax = 2147483647
-export const llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMin = 10
+export const llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMin = 100
export const llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMax = 10000
export const llmAnalyticsEvaluationReportsCreateBodyCooldownMinutesMin = 60
@@ -689,26 +688,13 @@ export const LlmAnalyticsEvaluationReportsCreateBody = /* @__PURE__ */ zod.objec
.describe('* `scheduled` - Scheduled\n* `every_n` - Every N')
.optional()
.describe(
- "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.\n\n* `scheduled` - Scheduled\n* `every_n` - Every N"
+ "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.\n\n* `scheduled` - Scheduled\n* `every_n` - Every N"
),
rrule: zod
.string()
.optional()
.describe(
- "RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise."
- ),
- starts_at: zod.iso
- .datetime({ offset: true })
- .nullish()
- .describe(
- "Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise."
- ),
- timezone_name: zod
- .string()
- .max(llmAnalyticsEvaluationReportsCreateBodyTimezoneNameMax)
- .optional()
- .describe(
- "IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America/New_York'). Defaults to 'UTC'."
+ "RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise."
),
delivery_targets: zod
.unknown()
@@ -723,7 +709,6 @@ export const LlmAnalyticsEvaluationReportsCreateBody = /* @__PURE__ */ zod.objec
.optional()
.describe('Maximum number of evaluation runs included in each report. Defaults to 200.'),
enabled: zod.boolean().optional().describe('Whether report delivery is active. Disabled configs do not fire.'),
- deleted: zod.boolean().optional().describe('Set to true to soft-delete this report config.'),
report_prompt_guidance: zod
.string()
.optional()
@@ -736,7 +721,7 @@ export const LlmAnalyticsEvaluationReportsCreateBody = /* @__PURE__ */ zod.objec
.max(llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMax)
.nullish()
.describe(
- "Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'."
+ "Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'."
),
cooldown_minutes: zod
.number()
@@ -780,12 +765,10 @@ export const LlmAnalyticsEvaluationReportsPartialUpdateParams = /* @__PURE__ */
),
})
-export const llmAnalyticsEvaluationReportsPartialUpdateBodyTimezoneNameMax = 64
-
export const llmAnalyticsEvaluationReportsPartialUpdateBodyMaxSampleSizeMin = -2147483648
export const llmAnalyticsEvaluationReportsPartialUpdateBodyMaxSampleSizeMax = 2147483647
-export const llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMin = 10
+export const llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMin = 100
export const llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMax = 10000
export const llmAnalyticsEvaluationReportsPartialUpdateBodyCooldownMinutesMin = 60
@@ -794,32 +777,18 @@ export const llmAnalyticsEvaluationReportsPartialUpdateBodyCooldownMinutesMax =
export const llmAnalyticsEvaluationReportsPartialUpdateBodyDailyRunCapMax = 24
export const LlmAnalyticsEvaluationReportsPartialUpdateBody = /* @__PURE__ */ zod.object({
- evaluation: zod.string().optional().describe('UUID of the evaluation this report config belongs to.'),
frequency: zod
.enum(['scheduled', 'every_n'])
.describe('* `scheduled` - Scheduled\n* `every_n` - Every N')
.optional()
.describe(
- "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.\n\n* `scheduled` - Scheduled\n* `every_n` - Every N"
+ "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.\n\n* `scheduled` - Scheduled\n* `every_n` - Every N"
),
rrule: zod
.string()
.optional()
.describe(
- "RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise."
- ),
- starts_at: zod.iso
- .datetime({ offset: true })
- .nullish()
- .describe(
- "Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise."
- ),
- timezone_name: zod
- .string()
- .max(llmAnalyticsEvaluationReportsPartialUpdateBodyTimezoneNameMax)
- .optional()
- .describe(
- "IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America/New_York'). Defaults to 'UTC'."
+ "RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise."
),
delivery_targets: zod
.unknown()
@@ -834,7 +803,6 @@ export const LlmAnalyticsEvaluationReportsPartialUpdateBody = /* @__PURE__ */ zo
.optional()
.describe('Maximum number of evaluation runs included in each report. Defaults to 200.'),
enabled: zod.boolean().optional().describe('Whether report delivery is active. Disabled configs do not fire.'),
- deleted: zod.boolean().optional().describe('Set to true to soft-delete this report config.'),
report_prompt_guidance: zod
.string()
.optional()
@@ -847,7 +815,7 @@ export const LlmAnalyticsEvaluationReportsPartialUpdateBody = /* @__PURE__ */ zo
.max(llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMax)
.nullish()
.describe(
- "Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'."
+ "Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'."
),
cooldown_minutes: zod
.number()
@@ -867,18 +835,6 @@ export const LlmAnalyticsEvaluationReportsPartialUpdateBody = /* @__PURE__ */ zo
),
})
-/**
- * Hard delete of this model is not allowed. Use a patch API call to set "deleted" to true
- */
-export const LlmAnalyticsEvaluationReportsDestroyParams = /* @__PURE__ */ zod.object({
- id: zod.string().describe('A UUID string identifying this evaluation report.'),
- project_id: zod
- .string()
- .describe(
- "Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/."
- ),
-})
-
/**
* Trigger immediate report generation.
*/
diff --git a/services/mcp/src/tools/generated/ai_observability.ts b/services/mcp/src/tools/generated/ai_observability.ts
index a7f4b048be5e..80dfd99c59a4 100644
--- a/services/mcp/src/tools/generated/ai_observability.ts
+++ b/services/mcp/src/tools/generated/ai_observability.ts
@@ -20,7 +20,6 @@ import {
LlmAnalyticsClusteringJobsRetrieveParams,
LlmAnalyticsEvaluationConfigSetActiveKeyCreateBody,
LlmAnalyticsEvaluationReportsCreateBody,
- LlmAnalyticsEvaluationReportsDestroyParams,
LlmAnalyticsEvaluationReportsGenerateCreateParams,
LlmAnalyticsEvaluationReportsListQueryParams,
LlmAnalyticsEvaluationReportsPartialUpdateBody,
@@ -391,7 +390,7 @@ const llmaEvaluationList = (): ToolBase<typeof LlmaEvaluationListSchema, Schemas
},
})
-const LlmaEvaluationReportCreateSchema = LlmAnalyticsEvaluationReportsCreateBody.omit({ deleted: true })
+const LlmaEvaluationReportCreateSchema = LlmAnalyticsEvaluationReportsCreateBody
const llmaEvaluationReportCreate = (): ToolBase<typeof LlmaEvaluationReportCreateSchema, Schemas.EvaluationReport> => ({
name: 'llma-evaluation-report-create',
@@ -408,12 +407,6 @@ const llmaEvaluationReportCreate = (): ToolBase<typeof LlmaEvaluationReportCreat
if (params.rrule !== undefined) {
body['rrule'] = params.rrule
}
- if (params.starts_at !== undefined) {
- body['starts_at'] = params.starts_at
- }
- if (params.timezone_name !== undefined) {
- body['timezone_name'] = params.timezone_name
- }
if (params.delivery_targets !== undefined) {
body['delivery_targets'] = params.delivery_targets
}
@@ -444,22 +437,6 @@ const llmaEvaluationReportCreate = (): ToolBase<typeof LlmaEvaluationReportCreat
},
})
-const LlmaEvaluationReportDeleteSchema = LlmAnalyticsEvaluationReportsDestroyParams.omit({ project_id: true })
-
-const llmaEvaluationReportDelete = (): ToolBase<typeof LlmaEvaluationReportDeleteSchema, Schemas.EvaluationReport> => ({
- name: 'llma-evaluation-report-delete',
- schema: LlmaEvaluationReportDeleteSchema,
- handler: async (context: Context, params: z.infer<typeof LlmaEvaluationReportDeleteSchema>) => {
- const projectId = await context.stateManager.getProjectId()
- const result = await context.api.request<Schemas.EvaluationReport>({
- method: 'PATCH',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/llm_analytics/evaluation_reports/${encodeURIComponent(String(params.id))}/`,
- body: { deleted: true },
- })
- return result
- },
-})
-
const LlmaEvaluationReportGenerateSchema = LlmAnalyticsEvaluationReportsGenerateCreateParams.omit({ project_id: true })
const llmaEvaluationReportGenerate = (): ToolBase<typeof LlmaEvaluationReportGenerateSchema, unknown> => ({
@@ -504,6 +481,7 @@ const llmaEvaluationReportList = (): ToolBase<
method: 'GET',
path: `/api/projects/${encodeURIComponent(String(projectId))}/llm_analytics/evaluation_reports/`,
query: {
+ evaluation: params.evaluation,
limit: params.limit,
offset: params.offset,
},
@@ -540,27 +518,21 @@ const LlmaEvaluationReportUpdateSchema = LlmAnalyticsEvaluationReportsPartialUpd
project_id: true,
}).extend(LlmAnalyticsEvaluationReportsPartialUpdateBody.shape)
-const llmaEvaluationReportUpdate = (): ToolBase<typeof LlmaEvaluationReportUpdateSchema, Schemas.EvaluationReport> => ({
+const llmaEvaluationReportUpdate = (): ToolBase<
+ typeof LlmaEvaluationReportUpdateSchema,
+ Schemas.EvaluationReportUpdate
+> => ({
name: 'llma-evaluation-report-update',
schema: LlmaEvaluationReportUpdateSchema,
handler: async (context: Context, params: z.infer<typeof LlmaEvaluationReportUpdateSchema>) => {
const projectId = await context.stateManager.getProjectId()
const body: Record<string, unknown> = {}
- if (params.evaluation !== undefined) {
- body['evaluation'] = params.evaluation
- }
if (params.frequency !== undefined) {
body['frequency'] = params.frequency
}
if (params.rrule !== undefined) {
body['rrule'] = params.rrule
}
- if (params.starts_at !== undefined) {
- body['starts_at'] = params.starts_at
- }
- if (params.timezone_name !== undefined) {
- body['timezone_name'] = params.timezone_name
- }
if (params.delivery_targets !== undefined) {
body['delivery_targets'] = params.delivery_targets
}
@@ -570,9 +542,6 @@ const llmaEvaluationReportUpdate = (): ToolBase<typeof LlmaEvaluationReportUpdat
if (params.enabled !== undefined) {
body['enabled'] = params.enabled
}
- if (params.deleted !== undefined) {
- body['deleted'] = params.deleted
- }
if (params.report_prompt_guidance !== undefined) {
body['report_prompt_guidance'] = params.report_prompt_guidance
}
@@ -585,7 +554,7 @@ const llmaEvaluationReportUpdate = (): ToolBase<typeof LlmaEvaluationReportUpdat
if (params.daily_run_cap !== undefined) {
body['daily_run_cap'] = params.daily_run_cap
}
- const result = await context.api.request<Schemas.EvaluationReport>({
+ const result = await context.api.request<Schemas.EvaluationReportUpdate>({
method: 'PATCH',
path: `/api/projects/${encodeURIComponent(String(projectId))}/llm_analytics/evaluation_reports/${encodeURIComponent(String(params.id))}/`,
body,
@@ -1586,7 +1555,6 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'llma-evaluation-judge-models': llmaEvaluationJudgeModels,
'llma-evaluation-list': llmaEvaluationList,
'llma-evaluation-report-create': llmaEvaluationReportCreate,
- 'llma-evaluation-report-delete': llmaEvaluationReportDelete,
'llma-evaluation-report-generate': llmaEvaluationReportGenerate,
'llma-evaluation-report-get': llmaEvaluationReportGet,
'llma-evaluation-report-list': llmaEvaluationReportList,
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-create.json
index f141082934e8..5ee51a002c31 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-create.json
@@ -25,7 +25,7 @@
"type": "string"
},
"frequency": {
- "description": "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.\n\n* `scheduled` - Scheduled\n* `every_n` - Every N",
+ "description": "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.\n\n* `scheduled` - Scheduled\n* `every_n` - Every N",
"enum": ["scheduled", "every_n"],
"type": "string"
},
@@ -40,39 +40,21 @@
"type": "string"
},
"rrule": {
- "description": "RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise.",
- "type": "string"
- },
- "starts_at": {
- "anyOf": [
- {
- "format": "date-time",
- "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise."
- },
- "timezone_name": {
- "description": "IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America/New_York'). Defaults to 'UTC'.",
- "maxLength": 64,
+ "description": "RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise.",
"type": "string"
},
"trigger_threshold": {
"anyOf": [
{
"maximum": 10000,
- "minimum": 10,
+ "minimum": 100,
"type": "number"
},
{
"type": "null"
}
],
- "description": "Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'."
+ "description": "Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'."
}
},
"required": ["evaluation"],
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-delete.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-delete.json
deleted file mode 100644
index e24e289397c0..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-delete.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "id": {
- "description": "A UUID string identifying this evaluation report.",
- "type": "string"
- }
- },
- "required": ["id"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-list.json
index 8331b796ac73..5c879f4fd38f 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-list.json
@@ -1,6 +1,10 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
+ "evaluation": {
+ "description": "Only return report configs for this evaluation UUID.",
+ "type": "string"
+ },
"limit": {
"description": "Number of results to return per page.",
"type": "number"
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-update.json
index f95531af96f7..f588303af317 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-evaluation-report-update.json
@@ -13,10 +13,6 @@
"minimum": 1,
"type": "number"
},
- "deleted": {
- "description": "Set to true to soft-delete this report config.",
- "type": "boolean"
- },
"delivery_targets": {
"description": "List of delivery targets. Each entry is either {type: 'email', value: '[email protected]'} or {type: 'slack', integration_id: <int>, channel: '<channel>'}. Slack integration_id must belong to this team."
},
@@ -24,12 +20,8 @@
"description": "Whether report delivery is active. Disabled configs do not fire.",
"type": "boolean"
},
- "evaluation": {
- "description": "UUID of the evaluation this report config belongs to.",
- "type": "string"
- },
"frequency": {
- "description": "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule + starts_at + timezone_name.\n\n* `scheduled` - Scheduled\n* `every_n` - Every N",
+ "description": "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.\n\n* `scheduled` - Scheduled\n* `every_n` - Every N",
"enum": ["scheduled", "every_n"],
"type": "string"
},
@@ -48,39 +40,21 @@
"type": "string"
},
"rrule": {
- "description": "RFC 5545 recurrence rule string (e.g. 'FREQ=WEEKLY;BYDAY=MO'). Must not contain DTSTART — the anchor is set via starts_at. Required when frequency is 'scheduled'; ignored otherwise.",
- "type": "string"
- },
- "starts_at": {
- "anyOf": [
- {
- "format": "date-time",
- "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Anchor datetime for the rrule (ISO 8601, UTC — must end in 'Z'). Local-time interpretation is controlled by timezone_name. Required when frequency is 'scheduled'; ignored otherwise."
- },
- "timezone_name": {
- "description": "IANA timezone name used to expand the rrule in local time so e.g. '9am' stays at 9am across DST transitions (e.g. 'America/New_York'). Defaults to 'UTC'.",
- "maxLength": 64,
+ "description": "RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise.",
"type": "string"
},
"trigger_threshold": {
"anyOf": [
{
"maximum": 10000,
- "minimum": 10,
+ "minimum": 100,
"type": "number"
},
{
"type": "null"
}
],
- "description": "Number of new evaluation results that triggers a report (every_n mode only). Min 10, max 10000. Defaults to 100. Required when frequency is 'every_n'."
+ "description": "Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'."
}
},
"required": ["id"],