From 5aa66fc07db9bd02330dfd9952da4c6d0e866b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=89=E9=91=AB=E5=8D=87?= Date: Tue, 23 Jun 2026 16:57:21 +0800 Subject: [PATCH] =?UTF-8?q?chore(backend):=20=E6=94=BE=E5=AE=BD=E9=80=92?= =?UTF-8?q?=E5=BD=92=E4=B8=8E=E5=BE=AA=E7=8E=AF=E6=A3=80=E6=B5=8B=E9=98=88?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - build_run_config recursion_limit 100 -> 250 - LoopDetectionMiddleware 默认阈值放宽(warn/hard/window/tool-freq) Co-Authored-By: Claude Opus 4.8 (1M context) --- .../backend/app/gateway/services.py | 2 +- .../middlewares/loop_detection_middleware.py | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/offline-backend-20260512/backend/app/gateway/services.py b/offline-backend-20260512/backend/app/gateway/services.py index d16243a3..761ee3eb 100644 --- a/offline-backend-20260512/backend/app/gateway/services.py +++ b/offline-backend-20260512/backend/app/gateway/services.py @@ -314,7 +314,7 @@ def build_run_config( the LangGraph Platform-compatible HTTP API and the IM channel path behave identically. """ - config: dict[str, Any] = {"recursion_limit": 100} + config: dict[str, Any] = {"recursion_limit": 250} if request_config: # LangGraph >= 0.6.0 introduced ``context`` as the preferred way to # pass thread-level data and rejects requests that include both diff --git a/offline-backend-20260512/backend/packages/harness/deerflow/agents/middlewares/loop_detection_middleware.py b/offline-backend-20260512/backend/packages/harness/deerflow/agents/middlewares/loop_detection_middleware.py index e7b053bd..b949163c 100644 --- a/offline-backend-20260512/backend/packages/harness/deerflow/agents/middlewares/loop_detection_middleware.py +++ b/offline-backend-20260512/backend/packages/harness/deerflow/agents/middlewares/loop_detection_middleware.py @@ -28,12 +28,12 @@ from langgraph.runtime import Runtime logger = logging.getLogger(__name__) # Defaults — can be overridden via constructor -_DEFAULT_WARN_THRESHOLD = 3 # inject warning after 3 identical calls -_DEFAULT_HARD_LIMIT = 5 # force-stop after 5 identical calls -_DEFAULT_WINDOW_SIZE = 20 # track last N tool calls +_DEFAULT_WARN_THRESHOLD = 8 # inject warning after 8 identical calls +_DEFAULT_HARD_LIMIT = 20 # force-stop after 20 identical calls +_DEFAULT_WINDOW_SIZE = 60 # track last N tool calls (must be >= hard_limit) _DEFAULT_MAX_TRACKED_THREADS = 100 # LRU eviction limit -_DEFAULT_TOOL_FREQ_WARN = 30 # warn after 30 calls to the same tool type -_DEFAULT_TOOL_FREQ_HARD_LIMIT = 50 # force-stop after 50 calls to the same tool type +_DEFAULT_TOOL_FREQ_WARN = 80 # warn after 80 calls to the same tool type +_DEFAULT_TOOL_FREQ_HARD_LIMIT = 120 # force-stop after 120 calls to the same tool type def _normalize_tool_call_args(raw_args: object) -> tuple[dict, str | None]: @@ -142,19 +142,19 @@ class LoopDetectionMiddleware(AgentMiddleware[AgentState]): Args: warn_threshold: Number of identical tool call sets before injecting - a warning message. Default: 3. + a warning message. Default: 8. hard_limit: Number of identical tool call sets before stripping - tool_calls entirely. Default: 5. + tool_calls entirely. Default: 20. window_size: Size of the sliding window for tracking calls. - Default: 20. + Default: 60. max_tracked_threads: Maximum number of threads to track before evicting the least recently used. Default: 100. tool_freq_warn: Number of calls to the same tool *type* (regardless of arguments) before injecting a frequency warning. Catches cross-file read loops that hash-based detection misses. - Default: 30. + Default: 80. tool_freq_hard_limit: Number of calls to the same tool type before - forcing a stop. Default: 50. + forcing a stop. Default: 120. """ def __init__(