Skip to content

Commit 4a48c18

Browse files
authored
♻️ Refactor: Remove the limit on the maximum number of execution steps for the agent. (#3400)
* ♻️ Refactor: Remove the limit on the maximum number of execution steps for the agent. * ♻️ Refactor: Remove the limit on the maximum number of execution steps for the agent. * ♻️ Refactor: Remove the limit on the maximum number of execution steps for the agent.
1 parent 5f13d6e commit 4a48c18

6 files changed

Lines changed: 23 additions & 18 deletions

File tree

backend/consts/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ class AgentInfoRequest(BaseModel):
547547
business_description: Optional[str] = None
548548
author: Optional[str] = None
549549
model_ids: Optional[List[int]] = None
550-
max_steps: Optional[int] = Field(default=None, ge=1, le=30)
550+
max_steps: Optional[int] = Field(default=None, ge=1)
551551
requested_output_tokens: Optional[int] = Field(default=None, gt=0)
552552
provide_run_summary: Optional[bool] = None
553553
duty_prompt: Optional[str] = None

backend/services/agent_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,9 +2242,9 @@ async def import_agent_by_agent_id(
22422242
enabled=True,
22432243
params=tool.params))
22442244
# check the validity of the agent parameters
2245-
if import_agent_info.max_steps <= 0 or import_agent_info.max_steps > 30:
2245+
if import_agent_info.max_steps <= 0:
22462246
raise ValueError(
2247-
f"Invalid max steps: {import_agent_info.max_steps}. max steps must be greater than 0 and less than 30.")
2247+
f"Invalid max steps: {import_agent_info.max_steps}. max steps must be greater than 0.")
22482248
if not import_agent_info.name.isidentifier():
22492249
raise ValueError(
22502250
f"Invalid agent name: {import_agent_info.name}. agent name must be a valid python variable name.")

frontend/app/[locale]/agents/components/agentInfo/AgentGenerateDetail.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,14 +1046,12 @@ export default function AgentGenerateDetail({}) {
10461046
{
10471047
type: "number",
10481048
min: 1,
1049-
max: 30,
10501049
message: t("businessLogic.config.maxSteps"),
10511050
},
10521051
]}
10531052
>
10541053
<InputNumber
10551054
min={1}
1056-
max={30}
10571055
style={{ width: "100%" }}
10581056
onBlur={() => {
10591057
const value = form.getFieldValue("mainAgentMaxStep");

sdk/nexent/core/agents/agent_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class AgentConfig(BaseModel):
200200
description: str = Field(description="Agent description")
201201
prompt_templates: Optional[Dict[str, Any]] = Field(description="Prompt templates", default=None)
202202
tools: List[ToolConfig] = Field(description="List of tool information")
203-
max_steps: int = Field(description="Maximum number of steps for current Agent", default=15, ge=1, le=30)
203+
max_steps: int = Field(description="Maximum number of steps for current Agent", default=15, ge=1)
204204
requested_output_tokens: Optional[int] = Field(
205205
description=(
206206
"Per-agent W2 output reserve override. None means inherit the "

test/backend/services/test_agent_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10863,7 +10863,7 @@ async def test_import_agent_by_agent_id_invalid_max_steps():
1086310863
mock_agent_info.description = "desc"
1086410864
mock_agent_info.business_description = "biz"
1086510865
mock_agent_info.author = "author"
10866-
mock_agent_info.max_steps = 35 # Too high (> 30)
10866+
mock_agent_info.max_steps = -1 # Invalid: must be > 0
1086710867
mock_agent_info.provide_run_summary = True
1086810868
mock_agent_info.duty_prompt = "duty"
1086910869
mock_agent_info.constraint_prompt = "constraint"

test/sdk/core/agents/test_agent_model.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,17 +1238,8 @@ def test_agent_config_max_steps_boundary(self):
12381238
)
12391239
assert config_max.max_steps == 30
12401240

1241-
def test_agent_config_max_steps_rejects_out_of_bounds(self):
1242-
"""Test AgentConfig rejects max_steps values outside 1-30 range."""
1243-
with pytest.raises(Exception):
1244-
agent_model_module.AgentConfig(
1245-
name="too_high",
1246-
description="Too high steps",
1247-
tools=[],
1248-
model_name="test",
1249-
max_steps=31
1250-
)
1251-
1241+
def test_agent_config_max_steps_rejects_below_lower_bound(self):
1242+
"""Test AgentConfig rejects max_steps values below the lower bound (1)."""
12521243
with pytest.raises(Exception):
12531244
agent_model_module.AgentConfig(
12541245
name="too_low",
@@ -1258,6 +1249,22 @@ def test_agent_config_max_steps_rejects_out_of_bounds(self):
12581249
max_steps=0
12591250
)
12601251

1252+
def test_agent_config_max_steps_accepts_above_design_max(self):
1253+
"""Test AgentConfig accepts max_steps values above the design-maximum (30).
1254+
1255+
The model enforces ge=1 (lower bound) but does not enforce an upper bound.
1256+
Values above 30 are silently accepted; callers are responsible for enforcing
1257+
application-level limits if needed.
1258+
"""
1259+
config = agent_model_module.AgentConfig(
1260+
name="above_design_max",
1261+
description="Steps above 30",
1262+
tools=[],
1263+
model_name="test",
1264+
max_steps=31
1265+
)
1266+
assert config.max_steps == 31
1267+
12611268

12621269
class TestAgentVerificationConfig:
12631270
"""Tests for layered ReAct verification configuration."""

0 commit comments

Comments
 (0)