From 2b1fcb3e434298304c91921f0051baa83e9840c5 Mon Sep 17 00:00:00 2001 From: DanielWalnut <45447813+hetaoBackend@users.noreply.github.com> Date: Fri, 8 May 2026 15:05:24 +0800 Subject: [PATCH] fix(task): remove max_turns parameter from task tool interface (#2783) * fix(task): remove max_turns parameter from task tool interface Subagents should always use their configured max_turns value. Exposing this parameter allowed callers to override the admin-configured limit, which is undesirable. The value is now exclusively driven by subagent config (per-agent overrides and global defaults in config.yaml). Co-Authored-By: Claude Sonnet 4.6 * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Claude Sonnet 4.6 Co-authored-by: Willem Jiang Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- backend/CLAUDE.md | 2 +- .../packages/harness/deerflow/tools/builtins/task_tool.py | 5 ----- backend/tests/test_task_tool_core_logic.py | 3 +-- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md index 86e3f8476..080c61cad 100644 --- a/backend/CLAUDE.md +++ b/backend/CLAUDE.md @@ -266,7 +266,7 @@ Proxied through nginx: `/api/langgraph/*` → LangGraph, all other `/api/*` → - `setup_agent` - Bootstrap-only: persist a brand-new custom agent's `SOUL.md` and `config.yaml`. Bound only when `is_bootstrap=True`. - `update_agent` - Custom-agent-only: persist self-updates to the current agent's `SOUL.md` / `config.yaml` from inside a normal chat (partial update + atomic write). Bound when `agent_name` is set and `is_bootstrap=False`. 4. **Subagent tool** (if enabled): - - `task` - Delegate to subagent (description, prompt, subagent_type, max_turns) + - `task` - Delegate to subagent (description, prompt, subagent_type) **Community tools** (`packages/harness/deerflow/community/`): - `tavily/` - Web search (5 results default) and web fetch (4KB limit) diff --git a/backend/packages/harness/deerflow/tools/builtins/task_tool.py b/backend/packages/harness/deerflow/tools/builtins/task_tool.py index 0154f6a7a..a124e00ba 100644 --- a/backend/packages/harness/deerflow/tools/builtins/task_tool.py +++ b/backend/packages/harness/deerflow/tools/builtins/task_tool.py @@ -54,7 +54,6 @@ async def task_tool( prompt: str, subagent_type: str, tool_call_id: Annotated[str, InjectedToolCallId], - max_turns: int | None = None, ) -> str: """Delegate a task to a specialized subagent that runs in its own context. @@ -90,7 +89,6 @@ async def task_tool( description: A short (3-5 word) description of the task for logging/display. ALWAYS PROVIDE THIS PARAMETER FIRST. prompt: The task description for the subagent. Be specific and clear about what needs to be done. ALWAYS PROVIDE THIS PARAMETER SECOND. subagent_type: The type of subagent to use. ALWAYS PROVIDE THIS PARAMETER THIRD. - max_turns: Optional maximum number of agent turns. Defaults to subagent's configured max. """ runtime_app_config = _get_runtime_app_config(runtime) available_subagent_names = get_available_subagent_names(app_config=runtime_app_config) if runtime_app_config is not None else get_available_subagent_names() @@ -112,9 +110,6 @@ async def task_tool( # each subagent loads its own skills based on config, injected as conversation items). # No longer appended to system_prompt here. - if max_turns is not None: - overrides["max_turns"] = max_turns - # Extract parent context from runtime sandbox_state = None thread_data = None diff --git a/backend/tests/test_task_tool_core_logic.py b/backend/tests/test_task_tool_core_logic.py index 428b7a066..3be1e4b5c 100644 --- a/backend/tests/test_task_tool_core_logic.py +++ b/backend/tests/test_task_tool_core_logic.py @@ -221,7 +221,6 @@ def test_task_tool_emits_running_and_completed_events(monkeypatch): prompt="collect diagnostics", subagent_type="general-purpose", tool_call_id="tc-123", - max_turns=7, ) assert output == "Task Succeeded. Result: all done" @@ -229,7 +228,7 @@ def test_task_tool_emits_running_and_completed_events(monkeypatch): assert captured["task_id"] == "tc-123" assert captured["executor_kwargs"]["thread_id"] == "thread-1" assert captured["executor_kwargs"]["parent_model"] == "ark-model" - assert captured["executor_kwargs"]["config"].max_turns == 7 + assert captured["executor_kwargs"]["config"].max_turns == config.max_turns # Skills are no longer appended to system_prompt; they are loaded per-session # by SubagentExecutor and injected as conversation items (Codex pattern). assert captured["executor_kwargs"]["config"].system_prompt == "Base system prompt"