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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> Co-authored-by: Willem Jiang <willem.jiang@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
+1
-1
@@ -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`.
|
- `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`.
|
- `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):
|
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/`):
|
**Community tools** (`packages/harness/deerflow/community/`):
|
||||||
- `tavily/` - Web search (5 results default) and web fetch (4KB limit)
|
- `tavily/` - Web search (5 results default) and web fetch (4KB limit)
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ async def task_tool(
|
|||||||
prompt: str,
|
prompt: str,
|
||||||
subagent_type: str,
|
subagent_type: str,
|
||||||
tool_call_id: Annotated[str, InjectedToolCallId],
|
tool_call_id: Annotated[str, InjectedToolCallId],
|
||||||
max_turns: int | None = None,
|
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Delegate a task to a specialized subagent that runs in its own context.
|
"""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.
|
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.
|
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.
|
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)
|
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()
|
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).
|
# each subagent loads its own skills based on config, injected as conversation items).
|
||||||
# No longer appended to system_prompt here.
|
# No longer appended to system_prompt here.
|
||||||
|
|
||||||
if max_turns is not None:
|
|
||||||
overrides["max_turns"] = max_turns
|
|
||||||
|
|
||||||
# Extract parent context from runtime
|
# Extract parent context from runtime
|
||||||
sandbox_state = None
|
sandbox_state = None
|
||||||
thread_data = None
|
thread_data = None
|
||||||
|
|||||||
@@ -221,7 +221,6 @@ def test_task_tool_emits_running_and_completed_events(monkeypatch):
|
|||||||
prompt="collect diagnostics",
|
prompt="collect diagnostics",
|
||||||
subagent_type="general-purpose",
|
subagent_type="general-purpose",
|
||||||
tool_call_id="tc-123",
|
tool_call_id="tc-123",
|
||||||
max_turns=7,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert output == "Task Succeeded. Result: all done"
|
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["task_id"] == "tc-123"
|
||||||
assert captured["executor_kwargs"]["thread_id"] == "thread-1"
|
assert captured["executor_kwargs"]["thread_id"] == "thread-1"
|
||||||
assert captured["executor_kwargs"]["parent_model"] == "ark-model"
|
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
|
# Skills are no longer appended to system_prompt; they are loaded per-session
|
||||||
# by SubagentExecutor and injected as conversation items (Codex pattern).
|
# by SubagentExecutor and injected as conversation items (Codex pattern).
|
||||||
assert captured["executor_kwargs"]["config"].system_prompt == "Base system prompt"
|
assert captured["executor_kwargs"]["config"].system_prompt == "Base system prompt"
|
||||||
|
|||||||
Reference in New Issue
Block a user