openjiuwen_deepsearch directory layout
This document reflects the current deepsearch/openjiuwen_deepsearch tree and what each major area does.
Overview
openjiuwen_deepsearch/
├── algorithm/ # Core algorithms
│ ├── prompts/ # Prompt templates
│ ├── query_understanding/ # Query understanding (router/outliner/planner/interpreter)
│ ├── report/ # Report generation
│ ├── report_template/ # Template parse/generate
│ ├── research_collector/ # Gathering and evaluation
│ ├── source_trace/ # Provenance and validation
│ ├── source_tracer_infer/ # Provenance reasoning
│ └── user_feedback_processor/ # Post-report local edits from user feedback
├── framework/ # Framework integration
│ └── openjiuwen/
│ ├── agent/ # Workflow and nodes
│ ├── core/ # WorkflowAgent and controller
│ ├── tools/ # Search tool wrappers
│ └── llm/ # LLM factory
├── config/ # Configuration
├── common/ # Shared exceptions and status codes
├── utils/ # Utilities
└── llm/ # Unified LLM wrapper
Details
algorithm/ — core algorithms
Functions: Core algorithm implementations for each stage of the research workflow.
Main subdirectories:
- prompts/ - Prompt templates (
.md)synonym_rewrite_expand.md- Prompt for expansionsynonym_rewrite_polish.md- Prompt for polishingsynonym_rewrite_shorten.md- Prompt for shorteningsupplementary_search_task.md- Prompt for supplementary-search task generationsupplementary_search_rewrite_selected_only.md- Prompt for supplementary search that rewrites only the selected spansupplementary_search_rewrite_selected_and_related.md- Prompt for supplementary search that rewrites the entire related sectionnew_task_assessment.md- Prompt for assessing sufficiency of historical evidence for new-task requestsnew_task_rewrite_section.md- Prompt for rewriting sections based on new-task edit strategy
- query_understanding/ - Query understanding
interpreter.py- Generate clarification questionsoutliner.py- Generate outlinesplanner.py- Generate section plansrouter.py- Decide whether to enter deep search
- report/ - Report generation
report.py- Main report generation logicreport_utils.py- Report utility functionsconfig.py- Report style and formatting
- report_template/ - Template generation and parsing
template_generator.pytemplate_utils.py
- research_collector/ - Information collection and evaluation
collector_function.pydoc_evaluation.pytool_log.py
- source_trace/ - Provenance module
source_tracer.pychecker.pyadd_source.pycitation_checker_research.pycitation_verify_research.pycontent_analyzer.pysource_matcher.pysource_tracer_preprocessors.py
- source_tracer_infer/ - Provenance reasoning module
generate_html.pyhtml_template.pyinfer.pyinfer_call_model.pyinfer_extract_info.pynumber_node.pysupplement_graph.py
- user_feedback_processor/ - User-feedback local editing module
action_definitions.py- Mapping between frontend actions and unified internal actionscommon.py- Shared utilities (session/model context resolution, LLM invocation entry)history.py- Rewrite history and outline update managementnew_task_processor.py- New-task action processing logicreport_edit_utils.py- Tools for stripping citation / inference markers and updating offsetssection_locator.py- Locate the smallest Markdown heading block for a selectionsupplementary_search.py- Execution logic for supplementary search and local / whole-section rewritingsynonym_rewrite.py- Execution logic for expansion, polishing, and shorteninguser_feedback_processor.py- Parse feedback, validate, execute, and send results
framework/ — orchestration
Functions: Workflow and node orchestration based on openjiuwen.
Main subdirectories:
-
openjiuwen/agent/ - Workflows and nodes
workflow.py- Agent and workflow entrymain_graph_nodes.py- Main graph nodes (Start/Entry/Outline/Reporter/SourceTracer, etc.)editor_team_manager_node.py- Editor-team subgraph managerreasoning_writing_graph/- Editor-team subgraph nodes and stateeditor_team_nodes.pydependency_reasoning_team_nodes.pydependency_writing_team_nodes.pysection_context.py
collector_graph/- Information-collection subgraphcollector_execution_service.py- Reusable information-collection execution servicegraph_builder.pyinfo_collector.pycollector_context.py
agent_factory.py- Agent factorybase_node.py- Base class for nodessearch_context.py- Search context model
-
openjiuwen/core/workflow_agent/— WorkflowAgent & controllerconfig.py,workflow_controller.py,workflow_agent.py
-
openjiuwen/tools/— search toolsweb_search.py,local_search.py,search_api/(external_tool/,petal/,tavily/,serper/,xunfei/,local_search_api/,native_local_search_api/)
-
openjiuwen/llm/— LLM factoryllm_model_factory.py,llm_adapter.py
config/
config.py—LLMConfig,AgentConfig,ServiceConfig, etc.method.py— execution mode enumsearch_mode.py— search mode enum
common/
common_constants.pyexception.pystatus_code.py
utils/
common_utils/—llm_utils.py,security_utils.py,stream_utils.py,text_utils.py,url_utils.pyconstants_utils/—node_constants.py,session_contextvars.py,search_engine_constants.pydebug_utils/—node_debug.py,outline_visualization.py,result_exporter.pylog_utils/— logging helpersvalidation_utils/—field_validation.py,param_validation.pyrate_limiter_utils/—qps_limiter.py
llm/
llm_wrapper.py— unified LLM callsllm_request_adapter.py— LLM request parameter adaptation, including provider rules for the model thinking-mode switch
Module relationships
User request
↓
framework/openjiuwen/agent/workflow.py
├── validate & merge agent_config
├── init LLM & search tools
└── Runner.run_agent_streaming(...)
↓
framework/openjiuwen/agent/main_graph_nodes.py
├── StartNode
├── EntryNode → algorithm/query_understanding/router.py
├── [GenerateQuestionsNode -> FeedbackHandlerNode] (optional HITL)
├── OutlineNode / DependencyOutlineNode → algorithm/query_understanding/outliner.py
├── OutlineInteractionNode / DependencyOutlineInteractionNode (optional)
├── EditorTeamNode / DependencyReasoningTeamNode / DependencyWritingTeamNode
│ ├── ResearchPlanReasoningNode → algorithm/query_understanding/planner.py
│ ├── InfoCollectorNode → collector_graph/
│ └── SubReporterNode → algorithm/report/report.py
├── ReporterNode → algorithm/report/report.py
├── SourceTracerNode → algorithm/source_trace/
├── SourceTracerInferNode → algorithm/source_tracer_infer/
└── UserFeedbackProcessorNode → algorithm/user_feedback_processor/
Where to look
- Workflow →
framework/openjiuwen/agent/ - Algorithms →
algorithm/ - Config →
config/config.py - Web search backends →
framework/openjiuwen/tools/search_api/ - Prompts →
algorithm/prompts/ - Context model →
framework/openjiuwen/agent/search_context.py
Design principles
- Layering:
algorithm/= logic;framework/= orchestration. - Modularity: nodes stay decoupled from algorithm details.
- Configuration:
config/is the single place for tunables. - Reuse:
utils/holds shared infrastructure.