deer-flow/src/prompts/planner_model.py
Willem Jiang 2e010a4619
feat: add analysis step type for non-code reasoning tasks (#677) (#723)
Add a new "analysis" step type to handle reasoning and synthesis tasks
that don't require code execution, addressing the concern that routing
all non-search tasks to the coder agent was inappropriate.

Changes:
- Add ANALYSIS enum value to StepType in planner_model.py
- Create analyst_node for pure LLM reasoning without tools
- Update graph routing to route analysis steps to analyst agent
- Add analyst agent to AGENT_LLM_MAP configuration
- Create analyst prompts (English and Chinese)
- Update planner prompts with guidance on choosing between
  analysis (reasoning/synthesis) and processing (code execution)
- Change default step_type inference from "processing" to "analysis"
  when need_search=false

Co-authored-by: Willem Jiang <143703838+willem-bd@users.noreply.github.com>
2025-11-29 09:46:55 +08:00

60 lines
2.0 KiB
Python

# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
# SPDX-License-Identifier: MIT
from enum import Enum
from typing import List, Optional
from pydantic import BaseModel, Field
class StepType(str, Enum):
RESEARCH = "research"
ANALYSIS = "analysis"
PROCESSING = "processing"
class Step(BaseModel):
need_search: bool = Field(..., description="Must be explicitly set for each step")
title: str
description: str = Field(..., description="Specify exactly what data to collect")
step_type: StepType = Field(..., description="Indicates the nature of the step")
execution_res: Optional[str] = Field(
default=None, description="The Step execution result"
)
class Plan(BaseModel):
locale: str = Field(
..., description="e.g. 'en-US' or 'zh-CN', based on the user's language"
)
has_enough_context: bool
thought: str = Field(default="", description="Thinking process for the plan")
title: str
steps: List[Step] = Field(
default_factory=list,
description="Research & Processing steps to get more context",
)
class Config:
json_schema_extra = {
"examples": [
{
"has_enough_context": False,
"thought": (
"To understand the current market trends in AI, we need to gather comprehensive information."
),
"title": "AI Market Research Plan",
"steps": [
{
"need_search": True,
"title": "Current AI Market Analysis",
"description": (
"Collect data on market size, growth rates, major players, and investment trends in AI sector."
),
"step_type": "research",
}
],
}
]
}