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>
This commit is contained in:
Willem Jiang
2025-11-29 09:46:55 +08:00
committed by GitHub
parent 2cc19d6309
commit 2e010a4619
10 changed files with 264 additions and 67 deletions

View File

@@ -2103,7 +2103,8 @@ def test_planner_node_issue_650_missing_step_type_basic():
# Verify all steps have step_type after fix
assert isinstance(fixed_plan, dict)
assert fixed_plan["steps"][0]["step_type"] == "research"
assert fixed_plan["steps"][1]["step_type"] == "processing"
# Issue #677: non-search steps now default to "analysis" instead of "processing"
assert fixed_plan["steps"][1]["step_type"] == "analysis"
assert all("step_type" in step for step in fixed_plan["steps"])
@@ -2147,7 +2148,8 @@ def test_planner_node_issue_650_water_footprint_scenario():
assert len(fixed_plan["steps"]) == 3
assert fixed_plan["steps"][0]["step_type"] == "research"
assert fixed_plan["steps"][1]["step_type"] == "research"
assert fixed_plan["steps"][2]["step_type"] == "processing"
# Issue #677: non-search steps now default to "analysis" instead of "processing"
assert fixed_plan["steps"][2]["step_type"] == "analysis"
assert all("step_type" in step for step in fixed_plan["steps"])
@@ -2272,7 +2274,8 @@ def test_plan_validation_with_all_issue_650_error_scenarios():
# All steps should have step_type after fix
for step in fixed["steps"]:
assert "step_type" in step
assert step["step_type"] in ["research", "processing"]
# Issue #677: 'analysis' is now a valid step_type
assert step["step_type"] in ["research", "analysis", "processing"]
def test_clarification_skips_specific_topics():
"""Coordinator should skip clarification for already specific topics."""