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__(