From b804c7ed47fa6e8a267f1b787788d2c54c8b4803 Mon Sep 17 00:00:00 2001 From: Yansong Zhang <916125788@qq.com> Date: Mon, 13 Apr 2026 14:39:27 +0800 Subject: [PATCH] fix: restore SandboxExpiredRecordsCleanConfig, remove debug logs - Restore SandboxExpiredRecordsCleanConfig (billing/ops config that was mistakenly removed with sandbox execution code) - Remove [DEBUG-AGENT] logging from app_generate_service.py Made-with: Cursor --- api/configs/feature/__init__.py | 24 ++++++++++++++++++++++++ api/services/app_generate_service.py | 7 ------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/api/configs/feature/__init__.py b/api/configs/feature/__init__.py index 9ee674a7b5..703a82a9b3 100644 --- a/api/configs/feature/__init__.py +++ b/api/configs/feature/__init__.py @@ -1311,6 +1311,29 @@ class CollaborationConfig(BaseSettings): ) +class SandboxExpiredRecordsCleanConfig(BaseSettings): + SANDBOX_EXPIRED_RECORDS_CLEAN_GRACEFUL_PERIOD: NonNegativeInt = Field( + description="Graceful period in days for sandbox records clean after subscription expiration", + default=21, + ) + SANDBOX_EXPIRED_RECORDS_CLEAN_BATCH_SIZE: PositiveInt = Field( + description="Maximum number of records to process in each batch", + default=1000, + ) + SANDBOX_EXPIRED_RECORDS_CLEAN_BATCH_MAX_INTERVAL: PositiveInt = Field( + description="Maximum interval in milliseconds between batches", + default=200, + ) + SANDBOX_EXPIRED_RECORDS_RETENTION_DAYS: PositiveInt = Field( + description="Retention days for sandbox expired workflow_run records and message records", + default=30, + ) + SANDBOX_EXPIRED_RECORDS_CLEAN_TASK_LOCK_TTL: PositiveInt = Field( + description="Lock TTL for sandbox expired records clean task in seconds", + default=90000, + ) + + class AgentV2UpgradeConfig(BaseSettings): """Feature flags for transparent Agent V2 upgrade.""" @@ -1431,6 +1454,7 @@ class FeatureConfig( WorkspaceConfig, CollaborationConfig, AgentV2UpgradeConfig, + SandboxExpiredRecordsCleanConfig, LoginConfig, AccountConfig, SwaggerUIConfig, diff --git a/api/services/app_generate_service.py b/api/services/app_generate_service.py index 7086f4379d..4ebbc700db 100644 --- a/api/services/app_generate_service.py +++ b/api/services/app_generate_service.py @@ -52,20 +52,15 @@ class AppGenerateService: nonlocal started with lock: if started: - logger.info("[DEBUG-AGENT] _try_start: already started, skipping") return True try: - logger.info("[DEBUG-AGENT] _try_start: calling start_task()...") start_task() - logger.info("[DEBUG-AGENT] _try_start: start_task() succeeded") except Exception: - logger.exception("[DEBUG-AGENT] _try_start: Failed to enqueue streaming task") return False started = True return True channel_type = dify_config.PUBSUB_REDIS_CHANNEL_TYPE - logger.info("[DEBUG-AGENT] channel_type=%s", channel_type) if channel_type == "streams": # With Redis Streams, we can safely start right away; consumers can read past events. _try_start() @@ -228,10 +223,8 @@ class AppGenerateService: request_id=request_id, ) case AppMode.AGENT: - logger.info("[DEBUG-AGENT] Entered AGENT case, streaming=%s", streaming) workflow_id = args.get("workflow_id") workflow = cls._get_workflow(app_model, invoke_from, workflow_id) - logger.info("[DEBUG-AGENT] Got workflow id=%s", workflow.id) if streaming: with rate_limit_context(rate_limit, request_id):