fix: make loop detection thresholds configurable via config.yaml#2119
Open
Ricardo-M-L wants to merge 1 commit intobytedance:mainfrom
Open
fix: make loop detection thresholds configurable via config.yaml#2119Ricardo-M-L wants to merge 1 commit intobytedance:mainfrom
Ricardo-M-L wants to merge 1 commit intobytedance:mainfrom
Conversation
LoopDetectionMiddleware used hardcoded thresholds (warn_threshold=3, hard_limit=5) that caused false positives with smaller context window models like DeepSeek on legitimate retry-heavy tasks. This adds a `loop_detection` section to config.yaml with four tunable parameters: warn_threshold, hard_limit, window_size, and max_tracked_threads. Both the factory (create_deerflow_agent) and the lead_agent (make_lead_agent) paths now read these values from config. Default values preserve existing behavior for backwards compatibility. Fixes bytedance#2116
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LoopDetectionMiddlewareuses hardcoded thresholds (warn_threshold=3,hard_limit=5) that are not exposed inconfig.yaml. This causes false positives with smaller context window models (e.g. DeepSeek) on legitimate retry-heavy tasks.loop_detectionsection toconfig.yamlwith four tunable parameters (warn_threshold,hard_limit,window_size,max_tracked_threads). Both thecreate_deerflow_agentfactory and themake_lead_agentapplication factory now read these values from config.Changes
config.example.yamlloop_detectionsection with documented defaultsdeerflow/config/loop_detection_config.pygeconstraints)deerflow/config/app_config.pyloop_detectionfield toAppConfigdeerflow/agents/features.pyloop_detectionfield toRuntimeFeaturesdeerflow/agents/factory.pyLoopDetectionMiddlewareconstructordeerflow/agents/lead_agent/agent.pyLoopDetectionMiddlewareconstructorbackend/tests/test_loop_detection_config.pyExample usage
Fixes #2116
Test plan
test_loop_detection_middleware.pytests pass unchanged (backwards compat)test_loop_detection_config.pytests verify: default values, custom values, Pydantic validation, higher thresholds avoiding false positives, DeepSeek-friendly config scenarioAppConfigcorrectly parsesloop_detectionfrom YAML and falls back to defaults when omitted🤖 Generated with Claude Code