mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 16:10:09 +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>
54 lines
2.3 KiB
Python
54 lines
2.3 KiB
Python
"""Deep Solve capability — agentic-engine-based multi-step problem solving.
|
|
|
|
Thin shim that delegates to :class:`SolvePipeline`. All orchestration (the
|
|
pre-retrieve sub-DAG, per-step agentic loops with ``THINK`` / ``TOOL`` /
|
|
``FINISH`` / ``REPLAN``, replan back-edge, synthesize) lives in the pipeline
|
|
module; the capability just wires the manifest.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from deeptutor.agents.solve.pipeline import SolvePipeline
|
|
from deeptutor.capabilities.request_contracts import get_capability_request_schema
|
|
from deeptutor.core.capability_protocol import BaseCapability, CapabilityManifest
|
|
from deeptutor.core.context import UnifiedContext
|
|
from deeptutor.core.stream_bus import StreamBus
|
|
|
|
|
|
class DeepSolveCapability(BaseCapability):
|
|
manifest = CapabilityManifest(
|
|
name="deep_solve",
|
|
description="Multi-agent problem solving (Plan -> ReAct -> Write).",
|
|
stages=["planning", "reasoning", "writing"],
|
|
tools_used=["rag", "web_search", "code_execution", "reason"],
|
|
cli_aliases=["solve"],
|
|
request_schema=get_capability_request_schema("deep_solve"),
|
|
)
|
|
|
|
async def run(self, context: UnifiedContext, stream: StreamBus) -> None:
|
|
# Knowledge bases are the single source of truth for whether ``rag``
|
|
# is available. There is no separate "enable rag" toggle.
|
|
kb_name = context.knowledge_bases[0] if context.knowledge_bases else None
|
|
requested = list(
|
|
self.manifest.tools_used if context.enabled_tools is None else context.enabled_tools
|
|
)
|
|
# Drop ``rag`` from the user-visible toggle list — the pipeline mounts
|
|
# it itself when a KB is attached, and never when none is.
|
|
enabled_tools = [tool for tool in requested if tool != "rag"]
|
|
|
|
pipeline = SolvePipeline(
|
|
language=context.language,
|
|
kb_name=kb_name,
|
|
enabled_tools=enabled_tools,
|
|
)
|
|
await pipeline.run(
|
|
context=context,
|
|
question=context.user_message,
|
|
attachments=context.attachments,
|
|
conversation_context=str(
|
|
context.metadata.get("conversation_context_text", "") or ""
|
|
).strip(),
|
|
memory_context=str(context.memory_context or "").strip(),
|
|
stream=stream,
|
|
)
|