Files
DeepTutor/tests/agents/research/test_request_config.py
Bingxi Zhao (Frank) 23ca3024be refactor(agents): rebuild Deep Research / Deep Solve / Question on agentic engine
Replaces three bespoke multi-agent pipelines with orchestrators on top
of a shared agentic-engine primitive set (core/agentic/: labeled_step,
loop, tool_dispatch, usage, client). Each capability now lives in one
pipeline.py file with one pipeline.yaml prompt.

- Deep Research: Rephrase (ask_user loop) -> Decompose (OUTLINE) ->
  Research blocks (THINK/TOOL/APPEND/FINISH per topic, dynamic queue
  preserved) -> Reporting (OUTLINE/INTRO/SECTION/CONCLUSION).
  CitationManager and the dynamic topic queue are kept.
- Deep Solve: Pre-retrieve (KB-only, QUERIES/rag/SUMMARY) -> Plan ->
  per-step THINK/TOOL/FINISH/REPLAN loop with back-edge to Plan ->
  Synthesize. Step FINISH text flows into the next step's context.
- Question: coordinator + pipeline replace generator / idea_agent /
  models, with new history.py and mimic_source.py helpers.

Removed: research/agents/, research/research_pipeline.py,
research/prompts/{en,zh}/*.yaml (legacy multi-agent prompts);
solve/agents/, solve/memory/, solve/utils/, main_solver.py,
session_manager.py, tool_runtime.py and old prompts;
question/agents/{generator,idea_agent}.py, example.py, models.py,
old prompts; api/routers/solve.py (capability owns its own routing).

Adds shared agents/_shared/tool_composition.py for cross-pipeline
tool wiring. Updates deep_research/deep_solve/deep_question
capabilities to dispatch through the new pipelines.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:03:44 +08:00

92 lines
3.3 KiB
Python

"""Tests for the research request-config helpers.
The legacy multi-agent prompt manifests (rephrase_agent.yaml,
decompose_agent.yaml, research_agent.yaml, note_agent.yaml,
reporting_agent.yaml) were deleted in the agentic-loop refactor. The
``sources`` knob was retired alongside them — tool composition now
goes through ``compose_enabled_tools`` like chat, driven by the user's
composer toggles plus the attached KB (auto-mounted as ``rag``). What
remains is coverage for the public ``request_config`` helpers that
drive runtime composition.
"""
from __future__ import annotations
from deeptutor.agents.research.request_config import (
build_research_execution_policy,
build_research_runtime_config,
validate_research_request_config,
)
def test_validate_research_request_config_accepts_minimal_payload() -> None:
request = validate_research_request_config(
{
"mode": "notes",
"depth": "quick",
}
)
assert request.mode == "notes"
assert request.depth == "quick"
def test_build_research_execution_policy_maps_intent_to_internal_settings() -> None:
request = validate_research_request_config(
{
"mode": "comparison",
"depth": "deep",
}
)
policy = build_research_execution_policy(request_config=request)
assert policy["planning"]["rephrase"]["enabled"] is True
assert policy["planning"]["decompose"]["mode"] == "manual"
assert policy["researching"]["execution_mode"] == "parallel"
# Source-derived enable_* flags were removed: tool composition is
# delegated to the shared ``compose_enabled_tools`` policy at runtime.
assert "enable_rag" not in policy["researching"]
assert "enable_web_search" not in policy["researching"]
assert "enable_paper_search" not in policy["researching"]
assert "enable_run_code" not in policy["researching"]
assert "enabled_tools" not in policy["researching"]
assert policy["reporting"]["style"] == "comparison"
assert policy["queue"]["max_length"] == 8
def test_build_research_runtime_config_carries_intent_without_sources() -> None:
request = validate_research_request_config(
{
"mode": "learning_path",
"depth": "standard",
}
)
runtime = build_research_runtime_config(
base_config={
"research": {
"researching": {
"note_agent_mode": "auto",
"tool_timeout": 60,
"tool_max_retries": 2,
"paper_search_years_limit": 3,
},
"rag": {"default_mode": "hybrid"},
},
},
request_config=request,
kb_name="research-kb",
)
assert runtime["planning"]["decompose"]["mode"] == "auto"
assert runtime["planning"]["decompose"]["auto_max_subtopics"] == 4
assert runtime["researching"]["max_iterations"] == 3
assert runtime["researching"]["execution_mode"] == "series"
assert runtime["reporting"]["style"] == "learning_path"
assert runtime["queue"]["max_length"] == 5
assert runtime["rag"]["kb_name"] == "research-kb"
assert runtime["intent"]["mode"] == "learning_path"
assert runtime["intent"]["depth"] == "standard"
assert "sources" not in runtime["intent"]
assert "tools" not in runtime # no source-derived tools overrides