diff --git a/api/configs/feature/__init__.py b/api/configs/feature/__init__.py index c270e17ccc..608dbe4022 100644 --- a/api/configs/feature/__init__.py +++ b/api/configs/feature/__init__.py @@ -1161,6 +1161,10 @@ class SandboxExpiredRecordsCleanConfig(BaseSettings): description="Maximum number of records to process in each batch", default=1000, ) + SANDBOX_EXPIRED_RECORDS_RETENTION_DAYS: PositiveInt = Field( + description="Retention days for sandbox expired workflow_run records and message records", + default=30, + ) class PositionConfig(BaseSettings): @@ -1310,7 +1314,7 @@ class FeatureConfig( PositionConfig, RagEtlConfig, RepositoryConfig, - SandboxRecordsCleanConfig, + SandboxExpiredRecordsCleanConfig, SecurityConfig, TenantIsolatedTaskQueueConfig, ToolConfig, diff --git a/api/schedule/clean_workflow_runs_task.py b/api/schedule/clean_workflow_runs_task.py index dde5d46606..96c2f9afea 100644 --- a/api/schedule/clean_workflow_runs_task.py +++ b/api/schedule/clean_workflow_runs_task.py @@ -14,8 +14,11 @@ def clean_workflow_runs_task() -> None: """ click.echo( click.style( - f"Scheduled workflow run cleanup starting: cutoff={dify_config.WORKFLOW_LOG_RETENTION_DAYS} days, " - f"batch={dify_config.WORKFLOW_LOG_CLEANUP_BATCH_SIZE}", + ( + "Scheduled workflow run cleanup starting: " + f"cutoff={dify_config.SANDBOX_EXPIRED_RECORDS_RETENTION_DAYS} days, " + f"batch={dify_config.WORKFLOW_LOG_CLEANUP_BATCH_SIZE}" + ), fg="green", ) ) @@ -23,7 +26,7 @@ def clean_workflow_runs_task() -> None: start_time = datetime.now(UTC) WorkflowRunCleanup( - days=dify_config.WORKFLOW_LOG_RETENTION_DAYS, + days=dify_config.SANDBOX_EXPIRED_RECORDS_RETENTION_DAYS, batch_size=dify_config.WORKFLOW_LOG_CLEANUP_BATCH_SIZE, start_after=None, end_before=None,