File size: 4,448 Bytes
026ee5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# Orchestrators API Reference

This page documents the API for DeepCritical orchestrators.

## IterativeResearchFlow

**Module**: `src.orchestrator.research_flow`

**Purpose**: Single-loop research with search-judge-synthesize cycles.

### Methods

#### `run`

```python
async def run(
    self,
    query: str,
    background_context: str = "",
    max_iterations: int | None = None,
    max_time_minutes: float | None = None,
    token_budget: int | None = None
) -> AsyncGenerator[AgentEvent, None]
```

Runs iterative research flow.

**Parameters**:
- `query`: Research query string
- `background_context`: Background context (default: "")
- `max_iterations`: Maximum iterations (default: from settings)
- `max_time_minutes`: Maximum time in minutes (default: from settings)
- `token_budget`: Token budget (default: from settings)

**Yields**: `AgentEvent` objects for:
- `started`: Research started
- `search_complete`: Search completed
- `judge_complete`: Evidence evaluation completed
- `synthesizing`: Generating report
- `complete`: Research completed
- `error`: Error occurred

## DeepResearchFlow

**Module**: `src.orchestrator.research_flow`

**Purpose**: Multi-section parallel research with planning and synthesis.

### Methods

#### `run`

```python
async def run(
    self,
    query: str,
    background_context: str = "",
    max_iterations_per_section: int | None = None,
    max_time_minutes: float | None = None,
    token_budget: int | None = None
) -> AsyncGenerator[AgentEvent, None]
```

Runs deep research flow.

**Parameters**:
- `query`: Research query string
- `background_context`: Background context (default: "")
- `max_iterations_per_section`: Maximum iterations per section (default: from settings)
- `max_time_minutes`: Maximum time in minutes (default: from settings)
- `token_budget`: Token budget (default: from settings)

**Yields**: `AgentEvent` objects for:
- `started`: Research started
- `planning`: Creating research plan
- `looping`: Running parallel research loops
- `synthesizing`: Synthesizing results
- `complete`: Research completed
- `error`: Error occurred

## GraphOrchestrator

**Module**: `src.orchestrator.graph_orchestrator`

**Purpose**: Graph-based execution using Pydantic AI agents as nodes.

### Methods

#### `run`

```python
async def run(
    self,
    query: str,
    research_mode: str = "auto",
    use_graph: bool = True
) -> AsyncGenerator[AgentEvent, None]
```

Runs graph-based research orchestration.

**Parameters**:
- `query`: Research query string
- `research_mode`: Research mode ("iterative", "deep", or "auto")
- `use_graph`: Whether to use graph execution (default: True)

**Yields**: `AgentEvent` objects during graph execution.

## Orchestrator Factory

**Module**: `src.orchestrator_factory`

**Purpose**: Factory for creating orchestrators.

### Functions

#### `create_orchestrator`

```python
def create_orchestrator(
    search_handler: SearchHandlerProtocol,
    judge_handler: JudgeHandlerProtocol,
    config: dict[str, Any],
    mode: str | None = None
) -> Any
```

Creates an orchestrator instance.

**Parameters**:
- `search_handler`: Search handler protocol implementation
- `judge_handler`: Judge handler protocol implementation
- `config`: Configuration dictionary
- `mode`: Orchestrator mode ("simple", "advanced", "magentic", or None for auto-detect)

**Returns**: Orchestrator instance.

**Raises**:
- `ValueError`: If requirements not met

**Modes**:
- `"simple"`: Legacy orchestrator
- `"advanced"` or `"magentic"`: Magentic orchestrator (requires OpenAI API key)
- `None`: Auto-detect based on API key availability

## MagenticOrchestrator

**Module**: `src.orchestrator_magentic`

**Purpose**: Multi-agent coordination using Microsoft Agent Framework.

### Methods

#### `run`

```python
async def run(
    self,
    query: str,
    max_rounds: int = 15,
    max_stalls: int = 3
) -> AsyncGenerator[AgentEvent, None]
```

Runs Magentic orchestration.

**Parameters**:
- `query`: Research query string
- `max_rounds`: Maximum rounds (default: 15)
- `max_stalls`: Maximum stalls before reset (default: 3)

**Yields**: `AgentEvent` objects converted from Magentic events.

**Requirements**:
- `agent-framework-core` package
- OpenAI API key

## See Also

- [Architecture - Orchestrators](../architecture/orchestrators.md) - Architecture overview
- [Graph Orchestration](../architecture/graph-orchestration.md) - Graph execution details