mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 08:09:49 +08:00
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>
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
import pytest
|
|
|
|
from deeptutor.agents.question.agents.followup_agent import FollowupAgent
|
|
|
|
|
|
class CaptureFollowupAgent(FollowupAgent):
|
|
"""``FollowupAgent`` subclass that records every system prompt sent to
|
|
the LLM (so the language-directive injection can be asserted), while
|
|
short-circuiting the actual network call."""
|
|
|
|
def __init__(self, language: str = "zh") -> None:
|
|
self.language = language
|
|
self.prompts: dict[str, Any] = {
|
|
"system": "Followup system",
|
|
"answer_followup": (
|
|
"Question context:\n{question_context}\n\n"
|
|
"Conversation history:\n{history_context}\n\n"
|
|
"User follow-up:\n{user_message}\n"
|
|
),
|
|
}
|
|
self.captured_system_prompts: list[str] = []
|
|
|
|
async def stream_llm(self, **kwargs): # type: ignore[override]
|
|
self.captured_system_prompts.append(str(kwargs["system_prompt"]))
|
|
yield "已回答"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_followup_agent_appends_language_directive_to_system_prompt() -> None:
|
|
agent = CaptureFollowupAgent(language="zh")
|
|
|
|
reply = await agent.process(
|
|
user_message="为什么这题是这个答案?",
|
|
question_context={
|
|
"question_id": "q_1",
|
|
"question_type": "choice",
|
|
"question": "矩阵乘法什么时候有定义?",
|
|
"correct_answer": "当内维度一致时。",
|
|
"explanation": "矩阵 A 的列数必须等于矩阵 B 的行数。",
|
|
},
|
|
history_context="",
|
|
)
|
|
|
|
assert reply == "已回答"
|
|
assert agent.captured_system_prompts
|
|
assert "Followup system" in agent.captured_system_prompts[0]
|
|
assert "请严格使用中文(简体)" in agent.captured_system_prompts[0]
|