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(experiments): add retries to the experiment recalculation model (#72204)

Rodrigo Ilorod8b34480ca68
diff --git a/products/experiments/backend/migrations/0028_experimentmetricsrecalculation_metric_retries.py b/products/experiments/backend/migrations/0028_experimentmetricsrecalculation_metric_retries.py
new file mode 100644
index 000000000000..8b7d3d1c43c5
--- /dev/null
+++ b/products/experiments/backend/migrations/0028_experimentmetricsrecalculation_metric_retries.py
@@ -0,0 +1,17 @@
+# Generated by Django 5.2.14 on 2026-07-18 16:56
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("experiments", "0027_experiment_flag_cleanup_task_id"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="experimentmetricsrecalculation",
+ name="metric_retries",
+ field=models.JSONField(default=dict),
+ ),
+ ]
diff --git a/products/experiments/backend/migrations/max_migration.txt b/products/experiments/backend/migrations/max_migration.txt
index 4699de29c9af..6fece083f37a 100644
--- a/products/experiments/backend/migrations/max_migration.txt
+++ b/products/experiments/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0027_experiment_flag_cleanup_task_id
+0028_experimentmetricsrecalculation_metric_retries
diff --git a/products/experiments/backend/models/experiment.py b/products/experiments/backend/models/experiment.py
index a2f813118eb9..9050e1845ee2 100644
--- a/products/experiments/backend/models/experiment.py
+++ b/products/experiments/backend/models/experiment.py
@@ -512,13 +512,11 @@ class ExperimentMetricsRecalculation(TeamScopedRootMixin, UUIDModel):
status = models.CharField(max_length=20, choices=Status, default=Status.PENDING)
total_metrics = models.PositiveIntegerField(default=0)
+
metric_errors = models.JSONField(default=dict)
- # Internal: written by the discovery activity, used by the service to recompute recalc fingerprints. Not exposed by the API serializer.
+ metric_retries = models.JSONField(default=dict)
metric_uuids = models.JSONField(default=list)
- # Single data-window end shared by all metrics in the run. Set once when the run starts; every metric
- # (including retries) uses this value so all metrics cover the same window and retries overwrite rather than
- # orphan rows. Exposed by the API serializer as the data freshness cutoff for the run's results.
query_to = models.DateTimeField(null=True, blank=True)
trigger = models.CharField(max_length=30, choices=Trigger, default=Trigger.MANUAL)
diff --git a/products/experiments/backend/presentation/serializers.py b/products/experiments/backend/presentation/serializers.py
index d87d05e162e1..ec208fe49a0b 100644
--- a/products/experiments/backend/presentation/serializers.py
+++ b/products/experiments/backend/presentation/serializers.py
@@ -1233,6 +1233,16 @@ class ExperimentMetricsRecalculationSerializer(serializers.Serializer):
)
# Named metric_errors (not errors) to avoid shadowing DRF's reserved Serializer.errors property.
metric_errors = serializers.JSONField(read_only=True, help_text="Map of metric_uuid to error details")
+ metric_retries = serializers.JSONField(
+ read_only=True,
+ required=False,
+ help_text=(
+ "Transient retry state per metric_uuid: {attempt, max_attempts, error_type, message, "
+ "next_retry_at}. message is a user-safe description of the error that triggered the retry. "
+ "Present only while a metric is between failed attempts; cleared when it succeeds or "
+ "fails terminally, so treat entries for metrics that already have a result as stale."
+ ),
+ )
trigger = serializers.ChoiceField(
choices=ExperimentMetricsRecalculation.Trigger.choices,
read_only=True,
diff --git a/products/experiments/backend/recalculation.py b/products/experiments/backend/recalculation.py
index 7fc2176667cd..1fec8367e34c 100644
--- a/products/experiments/backend/recalculation.py
+++ b/products/experiments/backend/recalculation.py
@@ -189,6 +189,7 @@ def build_job_payload(
"completed_metrics": completed_metrics,
"failed_metrics": failed_metrics,
"metric_errors": recalc.metric_errors,
+ "metric_retries": recalc.metric_retries,
"trigger": recalc.trigger,
"created_at": recalc.created_at,
"started_at": recalc.started_at,
diff --git a/products/experiments/backend/temporal/models.py b/products/experiments/backend/temporal/models.py
index 8394d498e9ce..887b1d856a09 100644
--- a/products/experiments/backend/temporal/models.py
+++ b/products/experiments/backend/temporal/models.py
@@ -21,6 +21,10 @@ MAX_METRIC_ATTEMPTS = 8
# exponential schedule.
CONCURRENCY_LIMIT_RETRY_DELAY_SECONDS = 60
+RECALCULATION_RETRY_INITIAL_INTERVAL_SECONDS = 5
+RECALCULATION_RETRY_BACKOFF_COEFFICIENT = 2.0
+RECALCULATION_RETRY_MAX_INTERVAL_SECONDS = 60
+
# classify_experiment_query_error classes that are deterministic for a fixed query and data window: retrying
# burns a full ClickHouse query per attempt without changing the outcome, so the activity fails non-retryable
# and persists immediately. timeout is deliberately absent — the class conflates TIMEOUT_EXCEEDED with
diff --git a/products/experiments/backend/temporal/recalculation_activities.py b/products/experiments/backend/temporal/recalculation_activities.py
index b32967fb271f..977b1dd51843 100644
--- a/products/experiments/backend/temporal/recalculation_activities.py
+++ b/products/experiments/backend/temporal/recalculation_activities.py
@@ -55,7 +55,8 @@ async def calculate_experiment_metric_for_recalculation(
attempt a transient failure is persisted rather than re-raised silently, so the row reflects the real
outcome once Temporal stops retrying.
"""
- is_final_attempt = temporalio.activity.info().attempt >= MAX_METRIC_ATTEMPTS
+ attempt = temporalio.activity.info().attempt
+ is_final_attempt = attempt >= MAX_METRIC_ATTEMPTS
return await _calculate_experiment_metric_for_recalculation_sync(
- experiment_id, metric_uuid, recalculation_id, query_to, metric_type, is_final_attempt
+ experiment_id, metric_uuid, recalculation_id, query_to, metric_type, is_final_attempt, attempt
)
diff --git a/products/experiments/backend/temporal/recalculation_logic.py b/products/experiments/backend/temporal/recalculation_logic.py
index 7e7bdd6e9b1b..6e15afb88a25 100644
--- a/products/experiments/backend/temporal/recalculation_logic.py
+++ b/products/experiments/backend/temporal/recalculation_logic.py
@@ -29,7 +29,10 @@ from posthog.models.scoping import team_scope
from posthog.sync import database_sync_to_async
from products.experiments.backend.hogql_queries.base_query_utils import experiment_window_end
-from products.experiments.backend.hogql_queries.error_handling import classify_experiment_query_error
+from products.experiments.backend.hogql_queries.error_handling import (
+ classify_experiment_query_error,
+ get_user_friendly_message,
+)
from products.experiments.backend.hogql_queries.experiment_metric_fingerprint import compute_metric_fingerprint
from products.experiments.backend.hogql_queries.experiment_query_runner import ExperimentQueryRunner
from products.experiments.backend.hogql_queries.utils import get_experiment_stats_method
@@ -41,8 +44,12 @@ from products.experiments.backend.models.experiment import (
from products.experiments.backend.temporal.metric_resolution import build_metric, find_metric_dict
from products.experiments.backend.temporal.models import (
CONCURRENCY_LIMIT_RETRY_DELAY_SECONDS,
+ MAX_METRIC_ATTEMPTS,
METRIC_CALC_MAX_EXECUTION_TIME_SECONDS,
NON_RETRYABLE_ERROR_TYPES,
+ RECALCULATION_RETRY_BACKOFF_COEFFICIENT,
+ RECALCULATION_RETRY_INITIAL_INTERVAL_SECONDS,
+ RECALCULATION_RETRY_MAX_INTERVAL_SECONDS,
ExperimentMetricToRecalculate,
MetricRecalculationResult,
RecalculationProgressUpdate,
@@ -216,6 +223,9 @@ def _update_recalculation_progress_sync(update: RecalculationProgressUpdate) ->
ExperimentMetricsRecalculation.objects.filter(id=update.recalculation_id, completed_at__isnull=True).update(
completed_at=timezone.now(),
status=update.status or ExperimentMetricsRecalculation.Status.COMPLETED,
+ # The run is terminal, so no retry can be pending. Sweeps entries orphaned by a hard-killed
+ # final attempt, which never reaches the activity-local cleanup branches.
+ metric_retries={},
)
== 1
)
@@ -330,6 +340,61 @@ def _record_failure(recalculation_id: str, metric_uuid: str, step: str, message:
recalc.save(update_fields=["metric_errors"])
+def _estimated_retry_delay_seconds(attempt: int) -> float:
+ """Mirror of the workflow's RetryPolicy backoff for the attempt that just failed."""
+ return min(
+ RECALCULATION_RETRY_INITIAL_INTERVAL_SECONDS * RECALCULATION_RETRY_BACKOFF_COEFFICIENT ** (attempt - 1),
+ RECALCULATION_RETRY_MAX_INTERVAL_SECONDS,
+ )
+
+
+_RETRY_SAFE_MESSAGES: dict[str, str] = {
+ "rate_limited": "The query was deferred because the cluster is at capacity.",
+ "timeout": "The query timed out.",
+ "out_of_memory": "The query ran out of memory.",
+ "byte_limit": "The query read too much data.",
+ "server_error": "The query failed with a server error.",
+}
+
+
+def _safe_retry_message(error: Exception, error_type: str) -> str:
+ """Raw exception text can embed the executed query, including substituted warehouse credentials
+ (this path runs the runner with user_facing=False, which keeps exceptions raw), and metric_retries
+ is visible to anyone with experiment read access. Persist only type-derived copy; the raw error
+ stays in logs and error tracking."""
+ return get_user_friendly_message(error) or _RETRY_SAFE_MESSAGES.get(
+ error_type, _RETRY_SAFE_MESSAGES["server_error"]
+ )
+
+
+def _record_retry(
+ recalculation_id: str, metric_uuid: str, attempt: int, error_type: str, message: str, delay_seconds: float
+) -> None:
+ """Transient attempt state for the UI, keyed by metric_uuid; overwritten per attempt, removed by the
+ metric's terminal write. Carries a user-safe description of the error that triggered the retry;
+ next_retry_at is an estimate (worker pickup adds slack after it passes)."""
+ with transaction.atomic():
+ recalc = ExperimentMetricsRecalculation.objects.select_for_update().get(id=recalculation_id)
+ metric_retries = recalc.metric_retries or {}
+ metric_retries[metric_uuid] = {
+ "attempt": attempt,
+ "max_attempts": MAX_METRIC_ATTEMPTS,
+ "error_type": error_type,
+ "message": message[:_MAX_ERROR_MESSAGE_LENGTH],
+ "next_retry_at": (timezone.now() + timedelta(seconds=delay_seconds)).isoformat(),
+ }
+ recalc.metric_retries = metric_retries
+ recalc.save(update_fields=["metric_retries"])
+
+
+def _clear_retry(recalculation_id: str, metric_uuid: str) -> None:
+ with transaction.atomic():
+ recalc = ExperimentMetricsRecalculation.objects.select_for_update().get(id=recalculation_id)
+ if metric_uuid in (recalc.metric_retries or {}):
+ recalc.metric_retries.pop(metric_uuid)
+ recalc.save(update_fields=["metric_retries"])
+
+
def _store_result(
*,
experiment_id: int,
@@ -364,6 +429,7 @@ def _store_result(
def _fail(recalculation_id: str, metric_uuid: str, step: str, message: str) -> MetricRecalculationResult:
"""Record a failure on the job (lookup step: job-only; calculation step: also persists a result row upstream)."""
_record_failure(recalculation_id, metric_uuid, step, message)
+ _clear_retry(recalculation_id, metric_uuid)
return MetricRecalculationResult(
metric_uuid=metric_uuid, success=False, error_step=step, error_message=message[:_MAX_ERROR_MESSAGE_LENGTH]
)
@@ -444,6 +510,7 @@ def _calculate_experiment_metric_for_recalculation_sync(
query_to: str,
metric_type: str = "primary",
is_final_attempt: bool = True,
+ attempt: int = 1,
) -> MetricRecalculationResult:
close_old_connections()
@@ -522,20 +589,15 @@ def _calculate_experiment_metric_for_recalculation_sync(
status=ExperimentMetricResult.Status.COMPLETED,
).exists()
if already_computed:
+ # A crash between the result write and the retry cleanup on a prior attempt lands here on the
+ # next one; clear so a completed metric can't keep reporting as retrying.
+ _clear_retry(recalculation_id, metric_uuid)
return MetricRecalculationResult(metric_uuid=metric_uuid, success=True)
- # Deterministic per-metric-per-run id. ClickHouse stamps it into the query_id as
- # `{team_id}_{client_query_id}_{random}`, so the stored value is a greppable prefix for
- # `system.query_log` (covers every attempt, including Temporal retries). Bound before the try so the
- # failure paths can always persist it.
client_query_id = f"experiment_metric_recalc_{recalculation_id}_{metric_uuid}"
calc_started_at = time.perf_counter()
try:
- # Metric build + query live inside the try so unexpected shapes surface as a calculation-step failure.
- # as_of pins the run's shared query_to as the window's evaluation instant (the runner caps it at
- # end_date). Without it each metric defaults to its own now(), giving slightly different windows —
- # defeating the "one query_to for the whole run" guarantee.
runner = ExperimentQueryRunner(
query=ExperimentQuery(experiment_id=experiment_id, metric=build_metric(metric_dict)),
team=experiment.team,
@@ -585,6 +647,7 @@ def _calculate_experiment_metric_for_recalculation_sync(
{"duration_ms": round((time.perf_counter() - calc_started_at) * 1000)},
trigger=state.trigger,
)
+ _clear_retry(recalculation_id, metric_uuid)
return MetricRecalculationResult(metric_uuid=metric_uuid, success=True)
except (StatisticError, ZeroDivisionError) as e:
@@ -657,6 +720,19 @@ def _calculate_experiment_metric_for_recalculation_sync(
is_final_attempt=is_final_attempt,
error_class=type(e).__name__,
)
+ if is_final_attempt:
+ _clear_retry(recalculation_id, metric_uuid)
+ else:
+ # Exact, not estimated: this branch sets the delay explicitly via next_retry_delay.
+ error_type = classify_experiment_query_error(e)
+ _record_retry(
+ recalculation_id,
+ metric_uuid,
+ attempt,
+ error_type,
+ _safe_retry_message(e, error_type),
+ CONCURRENCY_LIMIT_RETRY_DELAY_SECONDS,
+ )
raise ApplicationError(
message,
type=type(e).__name__,
@@ -708,6 +784,17 @@ def _calculate_experiment_metric_for_recalculation_sync(
is_final_attempt=is_final_attempt,
error_type=error_type,
)
+ if is_final_attempt or is_permanent:
+ _clear_retry(recalculation_id, metric_uuid)
+ else:
+ _record_retry(
+ recalculation_id,
+ metric_uuid,
+ attempt,
+ error_type,
+ _safe_retry_message(e, error_type),
+ _estimated_retry_delay_seconds(attempt),
+ )
if is_permanent:
raise ApplicationError(message, type=error_type, non_retryable=True) from e
raise
diff --git a/products/experiments/backend/temporal/recalculation_workflow.py b/products/experiments/backend/temporal/recalculation_workflow.py
index 92cfdbdf7deb..1856217fbe76 100644
--- a/products/experiments/backend/temporal/recalculation_workflow.py
+++ b/products/experiments/backend/temporal/recalculation_workflow.py
@@ -11,6 +11,9 @@ with temporalio.workflow.unsafe.imports_passed_through():
from products.experiments.backend.temporal.models import (
MAX_METRIC_ATTEMPTS,
METRIC_CALC_ACTIVITY_TIMEOUT_SECONDS,
+ RECALCULATION_RETRY_BACKOFF_COEFFICIENT,
+ RECALCULATION_RETRY_INITIAL_INTERVAL_SECONDS,
+ RECALCULATION_RETRY_MAX_INTERVAL_SECONDS,
ExperimentMetricsRecalculationWorkflowInputs,
RecalculationProgressUpdate,
)
@@ -105,8 +108,9 @@ class ExperimentMetricsRecalculationWorkflow(PostHogWorkflow):
temporalio.workflow.logger.info(f"running recalc {recalculation_id} with {len(metrics)} metrics")
calc_retry_policy = RetryPolicy(
- initial_interval=timedelta(seconds=5),
- maximum_interval=timedelta(seconds=60),
+ initial_interval=timedelta(seconds=RECALCULATION_RETRY_INITIAL_INTERVAL_SECONDS),
+ backoff_coefficient=RECALCULATION_RETRY_BACKOFF_COEFFICIENT,
+ maximum_interval=timedelta(seconds=RECALCULATION_RETRY_MAX_INTERVAL_SECONDS),
maximum_attempts=MAX_METRIC_ATTEMPTS,
)
results = await asyncio.gather(
diff --git a/products/experiments/backend/temporal/test_recalculation_activities.py b/products/experiments/backend/temporal/test_recalculation_activities.py
index bfe39c7f8776..548f9dfe4039 100644
--- a/products/experiments/backend/temporal/test_recalculation_activities.py
+++ b/products/experiments/backend/temporal/test_recalculation_activities.py
@@ -27,6 +27,7 @@ from products.experiments.backend.models.experiment import (
)
from products.experiments.backend.temporal.models import (
CONCURRENCY_LIMIT_RETRY_DELAY_SECONDS,
+ MAX_METRIC_ATTEMPTS,
RecalculationProgressUpdate,
)
from products.experiments.backend.temporal.recalc_fingerprint import compute_recalc_fingerprint
@@ -61,9 +62,12 @@ def _calculate(
query_to: str,
metric_type: str = "primary",
is_final_attempt: bool = True,
+ attempt: int = 1,
):
with patch("products.experiments.backend.temporal.recalculation_logic.close_old_connections"):
- return _calculate_raw(experiment_id, metric_uuid, recalculation_id, query_to, metric_type, is_final_attempt)
+ return _calculate_raw(
+ experiment_id, metric_uuid, recalculation_id, query_to, metric_type, is_final_attempt, attempt
+ )
@pytest.mark.django_db(transaction=True)
@@ -266,6 +270,9 @@ class TestRecalculationActivities(BaseTest):
def test_mark_completed_is_first_write_wins_on_retry(self):
# Symmetric to mark_started: a retried finish activity must not re-stamp completed_at.
recalc = self._recalc(self._experiment(flag_key="progress-retry-finish"))
+ # A hard-killed final attempt can orphan a retry entry; finishing the run must sweep it.
+ recalc.metric_retries = {"m1": {"attempt": 7, "max_attempts": 8}}
+ recalc.save(update_fields=["metric_retries"])
def _finish() -> str | None:
return _update(
@@ -278,6 +285,7 @@ class TestRecalculationActivities(BaseTest):
_finish()
recalc.refresh_from_db()
+ assert recalc.metric_retries == {}
first_completed_at = recalc.completed_at
first_status = recalc.status
@@ -452,6 +460,80 @@ class TestCalculateActivity(BaseTest):
recalc.refresh_from_db()
assert "m1" in recalc.metric_errors
+ @parameterized.expand(
+ [
+ # (name, exc, expected_error_type, expected_delay_seconds, expected_message) — backpressure uses
+ # the explicit next_retry_delay; a generic transient on attempt 2 follows the policy backoff
+ # (5 * 2^1). The generic exception carries a fake credential to lock in that raw exception text
+ # (which can embed the executed query, warehouse secrets included) never reaches the API field.
+ (
+ "backpressure",
+ ConcurrencyLimitExceeded("quota"),
+ "rate_limited",
+ 60,
+ "The query was deferred because the cluster is at capacity.",
+ ),
+ (
+ "generic_transient",
+ RuntimeError("blip aws_access_key_id=AKIAFAKESECRET"),
+ "server_error",
+ 10,
+ "The query failed with a server error.",
+ ),
+ ]
+ )
+ @freeze_time("2026-05-29T13:00:00Z")
+ def test_transient_attempt_records_retry_state_and_success_clears_it(
+ self, name: str, exc: Exception, expected_error_type: str, expected_delay_seconds: int, expected_message: str
+ ):
+ # The retry entry is what the UI shows between attempts; without it the metric looks stuck. It must
+ # carry the attempt counters and a next_retry_at estimate, and vanish once the metric resolves.
+ exp = self._experiment(flag_key=f"calc-retry-{name}", metrics=[_mean_metric("m1")])
+ recalc = self._recalc(exp, metric_uuids=["m1"])
+
+ with patch("products.experiments.backend.temporal.recalculation_logic.ExperimentQueryRunner") as mock_runner:
+ mock_runner.return_value.run.side_effect = exc
+ with pytest.raises((type(exc), ApplicationError)):
+ _calculate(exp.id, "m1", str(recalc.id), _QUERY_TO, is_final_attempt=False, attempt=2)
+
+ recalc.refresh_from_db()
+ entry = recalc.metric_retries["m1"]
+ assert entry["attempt"] == 2
+ assert entry["max_attempts"] == MAX_METRIC_ATTEMPTS
+ assert entry["error_type"] == expected_error_type
+ assert entry["message"] == expected_message
+ assert "AKIAFAKESECRET" not in entry["message"]
+ next_retry_at = datetime.fromisoformat(entry["next_retry_at"])
+ assert (next_retry_at - timezone.now()).total_seconds() == expected_delay_seconds
+
+ with patch("products.experiments.backend.temporal.recalculation_logic.ExperimentQueryRunner") as mock_runner:
+ mock_runner.return_value.run.return_value.model_dump.return_value = {}
+ result = _calculate(exp.id, "m1", str(recalc.id), _QUERY_TO, attempt=3)
+
+ assert result.success is True
+ recalc.refresh_from_db()
+ assert recalc.metric_retries == {}
+
+ def test_terminal_failure_clears_retry_state(self):
+ # A metric that retried and then failed for good must not keep a stale "retrying" entry alongside
+ # its terminal error.
+ exp = self._experiment(flag_key="calc-retry-terminal", metrics=[_mean_metric("m1")])
+ recalc = self._recalc(exp, metric_uuids=["m1"])
+
+ with patch("products.experiments.backend.temporal.recalculation_logic.ExperimentQueryRunner") as mock_runner:
+ mock_runner.return_value.run.side_effect = RuntimeError("transient blip")
+ with pytest.raises(RuntimeError):
+ _calculate(exp.id, "m1", str(recalc.id), _QUERY_TO, is_final_attempt=False, attempt=2)
+ recalc.refresh_from_db()
+ assert "m1" in recalc.metric_retries
+
+ with pytest.raises(RuntimeError):
+ _calculate(exp.id, "m1", str(recalc.id), _QUERY_TO, is_final_attempt=True, attempt=8)
+
+ recalc.refresh_from_db()
+ assert recalc.metric_retries == {}
+ assert "m1" in recalc.metric_errors
+
@parameterized.expand(
[
("org_quota", ConcurrencyLimitExceeded("org quota saturated")),
@@ -613,12 +695,18 @@ class TestCalculateActivity(BaseTest):
result={"already": "computed"},
)
recalc = self._recalc(exp, metric_uuids=["m1"])
+ # A crash between a prior attempt's result write and retry cleanup lands on this path; the skip
+ # must still clear the entry so a completed metric can't keep reporting as retrying.
+ recalc.metric_retries = {"m1": {"attempt": 3, "max_attempts": 8}}
+ recalc.save(update_fields=["metric_retries"])
with patch("products.experiments.backend.temporal.recalculation_logic.ExperimentQueryRunner") as mock_runner:
result = _calculate(exp.id, "m1", str(recalc.id), _QUERY_TO)
mock_runner.assert_not_called()
assert result.success is True
+ recalc.refresh_from_db()
+ assert recalc.metric_retries == {}
# The existing row is left untouched: same id, same result.
rows = ExperimentMetricResult.objects.filter(experiment=exp, metric_uuid="m1", query_to=query_to)
assert rows.count() == 1
diff --git a/products/experiments/backend/temporal/test_recalculation_workflow.py b/products/experiments/backend/temporal/test_recalculation_workflow.py
index 3ddd5b46351c..44e45a3d85e8 100644
--- a/products/experiments/backend/temporal/test_recalculation_workflow.py
+++ b/products/experiments/backend/temporal/test_recalculation_workflow.py
@@ -183,6 +183,7 @@ class TestExperimentMetricsRecalculationWorkflow:
query_to: str,
metric_type: str,
is_final_attempt: bool,
+ attempt: int,
) -> MetricRecalculationResult:
recorded_flags.append(is_final_attempt)
raise RuntimeError("always fails")
diff --git a/products/experiments/frontend/generated/api.schemas.ts b/products/experiments/frontend/generated/api.schemas.ts
index bf5104eb1620..ea7dfeaa025e 100644
--- a/products/experiments/frontend/generated/api.schemas.ts
+++ b/products/experiments/frontend/generated/api.schemas.ts
@@ -1908,6 +1908,8 @@ export interface ExperimentMetricsRecalculationApi {
readonly failed_metrics: number
/** Map of metric_uuid to error details */
readonly metric_errors: unknown
+ /** Transient retry state per metric_uuid: {attempt, max_attempts, error_type, message, next_retry_at}. message is a user-safe description of the error that triggered the retry. Present only while a metric is between failed attempts; cleared when it succeeds or fails terminally, so treat entries for metrics that already have a result as stale. */
+ readonly metric_retries: unknown
/** What triggered this recalculation
*
* * `manual` - Manual
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 0a4eb5877001..62350f59939d 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -25534,6 +25534,8 @@ export namespace Schemas {
readonly failed_metrics: number;
/** Map of metric_uuid to error details */
readonly metric_errors: unknown;
+ /** Transient retry state per metric_uuid: {attempt, max_attempts, error_type, message, next_retry_at}. message is a user-safe description of the error that triggered the retry. Present only while a metric is between failed attempts; cleared when it succeeds or fails terminally, so treat entries for metrics that already have a result as stale. */
+ readonly metric_retries: unknown;
/** What triggered this recalculation
*
* * `manual` - Manual