Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

chore: remove agent turn limits (#19930)

Noviceb2ab40127938
diff --git a/api/core/agent/cot_agent_runner.py b/api/core/agent/cot_agent_runner.py
index 5212d797d87..4979f634321 100644
--- a/api/core/agent/cot_agent_runner.py
+++ b/api/core/agent/cot_agent_runner.py
@@ -63,7 +63,7 @@ class CotAgentRunner(BaseAgentRunner, ABC):
self._instruction = self._fill_in_inputs_from_external_data_tools(instruction, inputs)
iteration_step = 1
- max_iteration_steps = min(app_config.agent.max_iteration if app_config.agent else 5, 5) + 1
+ max_iteration_steps = min(app_config.agent.max_iteration, 99) + 1
# convert tools into ModelRuntime Tool format
tool_instances, prompt_messages_tools = self._init_prompt_tools()
diff --git a/api/core/agent/entities.py b/api/core/agent/entities.py
index e68b4f23561..143a3a51aa3 100644
--- a/api/core/agent/entities.py
+++ b/api/core/agent/entities.py
@@ -82,7 +82,7 @@ class AgentEntity(BaseModel):
strategy: Strategy
prompt: Optional[AgentPromptEntity] = None
tools: Optional[list[AgentToolEntity]] = None
- max_iteration: int = 5
+ max_iteration: int = 10
class AgentInvokeMessage(ToolInvokeMessage):
diff --git a/api/core/agent/fc_agent_runner.py b/api/core/agent/fc_agent_runner.py
index 611a55b30a8..5491689ecef 100644
--- a/api/core/agent/fc_agent_runner.py
+++ b/api/core/agent/fc_agent_runner.py
@@ -48,7 +48,7 @@ class FunctionCallAgentRunner(BaseAgentRunner):
assert app_config.agent
iteration_step = 1
- max_iteration_steps = min(app_config.agent.max_iteration, 5) + 1
+ max_iteration_steps = min(app_config.agent.max_iteration, 99) + 1
# continue to run until there is not any tool call
function_call_state = True
diff --git a/api/core/app/app_config/easy_ui_based_app/agent/manager.py b/api/core/app/app_config/easy_ui_based_app/agent/manager.py
index f503543d7bd..590b944c0d2 100644
--- a/api/core/app/app_config/easy_ui_based_app/agent/manager.py
+++ b/api/core/app/app_config/easy_ui_based_app/agent/manager.py
@@ -75,7 +75,7 @@ class AgentConfigManager:
strategy=strategy,
prompt=agent_prompt_entity,
tools=agent_tools,
- max_iteration=agent_dict.get("max_iteration", 5),
+ max_iteration=agent_dict.get("max_iteration", 10),
)
return None
diff --git a/docker/.env.example b/docker/.env.example
index 9d685277967..ac9536be035 100644
--- a/docker/.env.example
+++ b/docker/.env.example
@@ -802,7 +802,7 @@ MAX_TOOLS_NUM=10
MAX_PARALLEL_LIMIT=10
# The maximum number of iterations for agent setting
-MAX_ITERATIONS_NUM=5
+MAX_ITERATIONS_NUM=99
# ------------------------------
# Environment Variables for web Service
diff --git a/docker/docker-compose-template.yaml b/docker/docker-compose-template.yaml
index 256a6131aee..74a7b87bf9b 100644
--- a/docker/docker-compose-template.yaml
+++ b/docker/docker-compose-template.yaml
@@ -75,7 +75,7 @@ services:
LOOP_NODE_MAX_COUNT: ${LOOP_NODE_MAX_COUNT:-100}
MAX_TOOLS_NUM: ${MAX_TOOLS_NUM:-10}
MAX_PARALLEL_LIMIT: ${MAX_PARALLEL_LIMIT:-10}
- MAX_ITERATIONS_NUM: ${MAX_ITERATIONS_NUM:-5}
+ MAX_ITERATIONS_NUM: ${MAX_ITERATIONS_NUM:-99}
ENABLE_WEBSITE_JINAREADER: ${ENABLE_WEBSITE_JINAREADER:-true}
ENABLE_WEBSITE_FIRECRAWL: ${ENABLE_WEBSITE_FIRECRAWL:-true}
ENABLE_WEBSITE_WATERCRAWL: ${ENABLE_WEBSITE_WATERCRAWL:-true}
diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml
index a13f115cd24..41e86d015f7 100644
--- a/docker/docker-compose.yaml
+++ b/docker/docker-compose.yaml
@@ -354,7 +354,7 @@ x-shared-env: &shared-api-worker-env
LOOP_NODE_MAX_COUNT: ${LOOP_NODE_MAX_COUNT:-100}
MAX_TOOLS_NUM: ${MAX_TOOLS_NUM:-10}
MAX_PARALLEL_LIMIT: ${MAX_PARALLEL_LIMIT:-10}
- MAX_ITERATIONS_NUM: ${MAX_ITERATIONS_NUM:-5}
+ MAX_ITERATIONS_NUM: ${MAX_ITERATIONS_NUM:-99}
TEXT_GENERATION_TIMEOUT_MS: ${TEXT_GENERATION_TIMEOUT_MS:-60000}
PGUSER: ${PGUSER:-${DB_USERNAME}}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-${DB_PASSWORD}}
@@ -574,7 +574,7 @@ services:
LOOP_NODE_MAX_COUNT: ${LOOP_NODE_MAX_COUNT:-100}
MAX_TOOLS_NUM: ${MAX_TOOLS_NUM:-10}
MAX_PARALLEL_LIMIT: ${MAX_PARALLEL_LIMIT:-10}
- MAX_ITERATIONS_NUM: ${MAX_ITERATIONS_NUM:-5}
+ MAX_ITERATIONS_NUM: ${MAX_ITERATIONS_NUM:-99}
ENABLE_WEBSITE_JINAREADER: ${ENABLE_WEBSITE_JINAREADER:-true}
ENABLE_WEBSITE_FIRECRAWL: ${ENABLE_WEBSITE_FIRECRAWL:-true}
ENABLE_WEBSITE_WATERCRAWL: ${ENABLE_WEBSITE_WATERCRAWL:-true}
diff --git a/web/.env.example b/web/.env.example
index 51631c2437d..78b4f33e8c5 100644
--- a/web/.env.example
+++ b/web/.env.example
@@ -50,7 +50,7 @@ NEXT_PUBLIC_MAX_TOOLS_NUM=10
NEXT_PUBLIC_MAX_PARALLEL_LIMIT=10
# The maximum number of iterations for agent setting
-NEXT_PUBLIC_MAX_ITERATIONS_NUM=5
+NEXT_PUBLIC_MAX_ITERATIONS_NUM=99
NEXT_PUBLIC_ENABLE_WEBSITE_JINAREADER=true
NEXT_PUBLIC_ENABLE_WEBSITE_FIRECRAWL=true
diff --git a/web/config/index.ts b/web/config/index.ts
index af4da768350..66ccde2aad8 100644
--- a/web/config/index.ts
+++ b/web/config/index.ts
@@ -173,7 +173,7 @@ export const MAX_TOOLS_NUM = maxToolsNum
export const DEFAULT_AGENT_SETTING = {
enabled: false,
- max_iteration: 5,
+ max_iteration: 10,
strategy: AgentStrategy.functionCall,
tools: [],
}
@@ -295,7 +295,7 @@ else if (globalThis.document?.body?.getAttribute('data-public-loop-node-max-coun
export const LOOP_NODE_MAX_COUNT = loopNodeMaxCount
-let maxIterationsNum = 5
+let maxIterationsNum = 99
if (process.env.NEXT_PUBLIC_MAX_ITERATIONS_NUM && process.env.NEXT_PUBLIC_MAX_ITERATIONS_NUM !== '')
maxIterationsNum = Number.parseInt(process.env.NEXT_PUBLIC_MAX_ITERATIONS_NUM)