mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-13 02:24:44 +08:00
feat: add ultra mode
This commit is contained in:
@@ -233,11 +233,12 @@ def make_lead_agent(config: RunnableConfig):
|
||||
thinking_enabled = config.get("configurable", {}).get("thinking_enabled", True)
|
||||
model_name = config.get("configurable", {}).get("model_name") or config.get("configurable", {}).get("model")
|
||||
is_plan_mode = config.get("configurable", {}).get("is_plan_mode", False)
|
||||
print(f"thinking_enabled: {thinking_enabled}, model_name: {model_name}, is_plan_mode: {is_plan_mode}")
|
||||
subagent_enabled = config.get("configurable", {}).get("subagent_enabled", False)
|
||||
print(f"thinking_enabled: {thinking_enabled}, model_name: {model_name}, is_plan_mode: {is_plan_mode}, subagent_enabled: {subagent_enabled}")
|
||||
return create_agent(
|
||||
model=create_chat_model(name=model_name, thinking_enabled=thinking_enabled),
|
||||
tools=get_available_tools(model_name=model_name),
|
||||
tools=get_available_tools(model_name=model_name, subagent_enabled=subagent_enabled),
|
||||
middleware=_build_middlewares(config),
|
||||
system_prompt=apply_prompt_template(),
|
||||
system_prompt=apply_prompt_template(subagent_enabled=subagent_enabled),
|
||||
state_schema=ThreadState,
|
||||
)
|
||||
|
||||
@@ -3,6 +3,8 @@ from datetime import datetime
|
||||
from src.skills import load_skills
|
||||
|
||||
SUBAGENT_SECTION = """<subagent_system>
|
||||
**SUBAGENT MODE ENABLED**: You are running in subagent mode. Use the `task` tool proactively to delegate complex, multi-step tasks to specialized subagents.
|
||||
|
||||
You can delegate tasks to specialized subagents using the `task` tool. Subagents run in isolated context and return concise results.
|
||||
|
||||
**Available Subagents:**
|
||||
@@ -258,7 +260,7 @@ def _get_memory_context() -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def apply_prompt_template() -> str:
|
||||
def apply_prompt_template(subagent_enabled: bool = False) -> str:
|
||||
# Load only enabled skills
|
||||
skills = load_skills(enabled_only=True)
|
||||
|
||||
@@ -268,11 +270,9 @@ def apply_prompt_template() -> str:
|
||||
|
||||
config = get_app_config()
|
||||
container_base_path = config.skills.container_path
|
||||
subagents_enabled = config.subagents.enabled
|
||||
except Exception:
|
||||
# Fallback to defaults if config fails
|
||||
container_base_path = "/mnt/skills"
|
||||
subagents_enabled = True
|
||||
|
||||
# Generate skills list XML with paths (path points to SKILL.md file)
|
||||
if skills:
|
||||
@@ -286,8 +286,8 @@ def apply_prompt_template() -> str:
|
||||
# Get memory context
|
||||
memory_context = _get_memory_context()
|
||||
|
||||
# Include subagent section only if enabled
|
||||
subagent_section = SUBAGENT_SECTION if subagents_enabled else ""
|
||||
# Include subagent section only if enabled (from runtime parameter)
|
||||
subagent_section = SUBAGENT_SECTION if subagent_enabled else ""
|
||||
|
||||
# Format the prompt with dynamic skills and memory
|
||||
prompt = SYSTEM_PROMPT_TEMPLATE.format(
|
||||
|
||||
@@ -11,7 +11,6 @@ from src.config.memory_config import load_memory_config_from_dict
|
||||
from src.config.model_config import ModelConfig
|
||||
from src.config.sandbox_config import SandboxConfig
|
||||
from src.config.skills_config import SkillsConfig
|
||||
from src.config.subagents_config import SubagentsConfig
|
||||
from src.config.summarization_config import load_summarization_config_from_dict
|
||||
from src.config.title_config import load_title_config_from_dict
|
||||
from src.config.tool_config import ToolConfig, ToolGroupConfig
|
||||
@@ -27,7 +26,6 @@ class AppConfig(BaseModel):
|
||||
tools: list[ToolConfig] = Field(default_factory=list, description="Available tools")
|
||||
tool_groups: list[ToolGroupConfig] = Field(default_factory=list, description="Available tool groups")
|
||||
skills: SkillsConfig = Field(default_factory=SkillsConfig, description="Skills configuration")
|
||||
subagents: SubagentsConfig = Field(default_factory=SubagentsConfig, description="Subagents configuration")
|
||||
extensions: ExtensionsConfig = Field(default_factory=ExtensionsConfig, description="Extensions configuration (MCP servers and skills state)")
|
||||
model_config = ConfigDict(extra="allow", frozen=False)
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
"""Configuration for subagents."""
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class SubagentsConfig(BaseModel):
|
||||
"""Configuration for subagents feature."""
|
||||
|
||||
enabled: bool = Field(default=True, description="Whether subagents are enabled")
|
||||
@@ -86,7 +86,8 @@ def task_tool(
|
||||
# Lazy import to avoid circular dependency
|
||||
from src.tools import get_available_tools
|
||||
|
||||
tools = get_available_tools(model_name=parent_model)
|
||||
# Subagents should not have subagent tools enabled (prevent recursive nesting)
|
||||
tools = get_available_tools(model_name=parent_model, subagent_enabled=False)
|
||||
|
||||
# Create executor
|
||||
executor = SubagentExecutor(
|
||||
|
||||
@@ -19,7 +19,12 @@ SUBAGENT_TOOLS = [
|
||||
]
|
||||
|
||||
|
||||
def get_available_tools(groups: list[str] | None = None, include_mcp: bool = True, model_name: str | None = None) -> list[BaseTool]:
|
||||
def get_available_tools(
|
||||
groups: list[str] | None = None,
|
||||
include_mcp: bool = True,
|
||||
model_name: str | None = None,
|
||||
subagent_enabled: bool = False,
|
||||
) -> list[BaseTool]:
|
||||
"""Get all available tools from config.
|
||||
|
||||
Note: MCP tools should be initialized at application startup using
|
||||
@@ -29,6 +34,7 @@ def get_available_tools(groups: list[str] | None = None, include_mcp: bool = Tru
|
||||
groups: Optional list of tool groups to filter by.
|
||||
include_mcp: Whether to include tools from MCP servers (default: True).
|
||||
model_name: Optional model name to determine if vision tools should be included.
|
||||
subagent_enabled: Whether to include subagent tools (task, task_status).
|
||||
|
||||
Returns:
|
||||
List of available tools.
|
||||
@@ -60,8 +66,8 @@ def get_available_tools(groups: list[str] | None = None, include_mcp: bool = Tru
|
||||
# Conditionally add tools based on config
|
||||
builtin_tools = BUILTIN_TOOLS.copy()
|
||||
|
||||
# Add subagent tools only if enabled
|
||||
if config.subagents.enabled:
|
||||
# Add subagent tools only if enabled via runtime parameter
|
||||
if subagent_enabled:
|
||||
builtin_tools.extend(SUBAGENT_TOOLS)
|
||||
logger.info("Including subagent tools (task, task_status)")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user