@lincoln504/pi-research 1.3.11 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli.mjs +5558 -4596
- package/dist/prompts/research-tool-usage.md +1 -1
- package/dist/prompts/researcher.md +1 -0
- package/dist/prompts/system-coordinator.md +1 -1
- package/dist/prompts/system-lead-router.md +122 -0
- package/dist/prompts/system-lead-synthesizer.md +46 -0
- package/dist/thread-worker.mjs +123 -30
- package/docs/ARCHITECTURE.md +69 -24
- package/docs/CHANGELOG.md +215 -0
- package/docs/CONFIGURATION.md +108 -8
- package/package.json +19 -11
- package/scripts/build.cjs +8 -1
- package/scripts/cleanup.cjs +26 -5
- package/scripts/setup.cjs +25 -1
- package/skills/pi-research/SKILL.md +1 -1
- package/src/cli.ts +41 -2
- package/src/config.ts +12 -8
- package/src/constants.ts +1 -1
- package/src/core/interfaces/observer-interfaces.ts +3 -3
- package/src/core/interfaces/orchestration-interfaces.ts +2 -0
- package/src/core/interfaces/planning-interfaces.ts +7 -1
- package/src/core/interfaces/scheduler-interfaces.ts +18 -2
- package/src/core/llm/agentic-repair.ts +7 -2
- package/src/core/llm/inject-date.ts +4 -1
- package/src/core/llm/llm-utils.ts +7 -0
- package/src/core/planning-service.ts +719 -91
- package/src/core/planning-utils.ts +21 -5
- package/src/core/service-initialization.ts +19 -3
- package/src/core/service-registry.ts +19 -3
- package/src/healthcheck/index.ts +11 -2
- package/src/index.ts +4 -3
- package/src/infrastructure/browser/browser-client.ts +68 -34
- package/src/infrastructure/browser/browser-task-scheduler.ts +220 -34
- package/src/infrastructure/browser/config.ts +77 -6
- package/src/infrastructure/browser/priority-task-queue.ts +55 -1
- package/src/infrastructure/browser/scheduler-factory.ts +12 -1
- package/src/infrastructure/browser/task-execution-service.ts +17 -7
- package/src/infrastructure/browser/thread-worker-browser.ts +66 -20
- package/src/infrastructure/browser/thread-worker-messaging.ts +38 -6
- package/src/infrastructure/browser/thread-worker.mjs +123 -30
- package/src/infrastructure/browser/thread-worker.ts +2 -2
- package/src/infrastructure/browser/worker-pool-manager.ts +127 -12
- package/src/infrastructure/embedding/embedding-client.ts +14 -4
- package/src/infrastructure/embedding/embedding-factory.ts +83 -15
- package/src/infrastructure/file-lock-service.ts +214 -19
- package/src/infrastructure/gpu-resource-service.ts +15 -1
- package/src/infrastructure/knowledge-store-service.ts +14 -0
- package/src/infrastructure/research-run-semaphore.ts +1 -1
- package/src/infrastructure/service-initialization.ts +7 -0
- package/src/knowledge/embedder-init.ts +60 -18
- package/src/knowledge/store.ts +11 -5
- package/src/logger.ts +11 -0
- package/src/orchestration/deep-research-orchestrator.ts +141 -87
- package/src/orchestration/quick-research-orchestrator.ts +11 -2
- package/src/orchestration/research-orchestration-service.ts +30 -1
- package/src/orchestration/research-synthesis-service.ts +53 -1
- package/src/orchestration/researcher-executor.ts +53 -2
- package/src/orchestration/researcher.ts +15 -2
- package/src/prompts/research-tool-usage.md +1 -1
- package/src/prompts/researcher.md +1 -0
- package/src/prompts/system-coordinator.md +1 -1
- package/src/prompts/system-lead-router.md +122 -0
- package/src/prompts/system-lead-synthesizer.md +46 -0
- package/src/sdk.ts +10 -1
- package/src/security/nvd-client.ts +55 -4
- package/src/security/osv-client.ts +13 -1
- package/src/tools/research-knowledge-search.ts +29 -4
- package/src/tools/scrape.ts +6 -0
- package/src/tools/search.ts +7 -0
- package/src/tools/security.ts +27 -9
- package/src/tools/stackexchange.ts +13 -7
- package/src/tools/youtube-transcript.ts +26 -12
- package/src/utils/cancellation.ts +36 -0
- package/src/utils/coverage-digest.ts +204 -0
- package/src/utils/llm-usage.ts +33 -6
- package/src/utils/log-utils.ts +16 -1
- package/src/utils/metrics-summary.ts +20 -4
- package/src/utils/metrics.ts +27 -1
- package/src/web-research/browser-search.ts +93 -20
- package/src/web-research/scraper-utils.ts +55 -14
- package/dist/prompts/system-lead-evaluator.md +0 -118
- package/src/prompts/system-lead-evaluator.md +0 -118
|
@@ -277,10 +277,18 @@ export interface SsrfSafeFetcher {
|
|
|
277
277
|
dispatcher: unknown;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
// Cached after first construction. `undefined` = not yet attempted
|
|
281
|
-
// undici unavailable (fall back to the global fetch
|
|
282
|
-
// validation only).
|
|
283
|
-
|
|
280
|
+
// Cached after first construction. `undefined` = not yet attempted; the promise
|
|
281
|
+
// resolves to `null` when undici is unavailable (fall back to the global fetch
|
|
282
|
+
// with request-time validation only).
|
|
283
|
+
//
|
|
284
|
+
// The PROMISE is cached, not the resolved value. Caching the value left a window
|
|
285
|
+
// between the `undefined` check and the assignment — an `await import('undici')`
|
|
286
|
+
// wide — during which every concurrent first caller built its OWN Agent. Only the
|
|
287
|
+
// last assignment survived in the cache, so the others were handed live Agents
|
|
288
|
+
// that nothing tracked: they opened keep-alive sockets and no shutdown path could
|
|
289
|
+
// ever close them, which is precisely the leak disposeSsrfSafeFetcher exists to
|
|
290
|
+
// prevent. Scrapes run concurrently by design, so the very first burst hit this.
|
|
291
|
+
let cachedSsrfFetcher: Promise<SsrfSafeFetcher | null> | undefined = undefined;
|
|
284
292
|
|
|
285
293
|
/**
|
|
286
294
|
* Build (once) an undici Agent whose connector resolves via ssrfSafeLookup, so
|
|
@@ -304,19 +312,52 @@ let cachedSsrfFetcher: SsrfSafeFetcher | null | undefined = undefined;
|
|
|
304
312
|
* Returns null if undici can't be loaded; callers then use the global fetch with
|
|
305
313
|
* no dispatcher (request-time validation still applies).
|
|
306
314
|
*/
|
|
307
|
-
export
|
|
308
|
-
|
|
315
|
+
export function getSsrfSafeFetcher(): Promise<SsrfSafeFetcher | null> {
|
|
316
|
+
// Assigned before the first await, so concurrent callers all join this one
|
|
317
|
+
// construction rather than each starting their own.
|
|
318
|
+
cachedSsrfFetcher ??= (async () => {
|
|
319
|
+
try {
|
|
320
|
+
const { Agent, fetch: undiciFetch } = await import('undici');
|
|
321
|
+
return {
|
|
322
|
+
fetch: undiciFetch as unknown as SsrfSafeFetcher['fetch'],
|
|
323
|
+
dispatcher: new Agent({ connect: { lookup: ssrfSafeLookup } }),
|
|
324
|
+
};
|
|
325
|
+
} catch (e) {
|
|
326
|
+
logger.warn(`[Scrapers] undici unavailable; connect-time SSRF pinning disabled (request-time validation still active): ${e instanceof Error ? e.message : String(e)}`);
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
})();
|
|
330
|
+
return cachedSsrfFetcher;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Close the cached SSRF Agent and drop the cache.
|
|
335
|
+
*
|
|
336
|
+
* The Agent is a process-lifetime singleton holding keep-alive sockets to every
|
|
337
|
+
* host scraped so far. The CLI hard-exits so it never notices, but an embedding
|
|
338
|
+
* host (the pi extension) keeps the process alive across SDK
|
|
339
|
+
* init/shutdown cycles, where those sockets would linger past a teardown that
|
|
340
|
+
* claims to have released everything.
|
|
341
|
+
*
|
|
342
|
+
* Clearing the cache is not optional: the SDK can be re-initialized in the same
|
|
343
|
+
* process, and a closed Agent left in the cache would fail every subsequent
|
|
344
|
+
* scrape. Resetting to `undefined` (not `null`) makes the next call rebuild it.
|
|
345
|
+
*/
|
|
346
|
+
export async function disposeSsrfSafeFetcher(): Promise<void> {
|
|
347
|
+
const pending = cachedSsrfFetcher;
|
|
348
|
+
cachedSsrfFetcher = undefined;
|
|
349
|
+
if (pending === undefined) return;
|
|
350
|
+
// Await the in-flight construction rather than skipping it: a dispose racing
|
|
351
|
+
// the first getSsrfSafeFetcher() would otherwise leave the Agent it is still
|
|
352
|
+
// building unreferenced and unclosed.
|
|
353
|
+
const cached = await pending.catch(() => null);
|
|
354
|
+
const closable = cached?.dispatcher as { close?: () => Promise<void> } | undefined;
|
|
355
|
+
if (!closable?.close) return;
|
|
309
356
|
try {
|
|
310
|
-
|
|
311
|
-
cachedSsrfFetcher = {
|
|
312
|
-
fetch: undiciFetch as unknown as SsrfSafeFetcher['fetch'],
|
|
313
|
-
dispatcher: new Agent({ connect: { lookup: ssrfSafeLookup } }),
|
|
314
|
-
};
|
|
357
|
+
await closable.close();
|
|
315
358
|
} catch (e) {
|
|
316
|
-
logger.
|
|
317
|
-
cachedSsrfFetcher = null;
|
|
359
|
+
logger.debug(`[Scrapers] Error closing SSRF dispatcher: ${e instanceof Error ? e.message : String(e)}`);
|
|
318
360
|
}
|
|
319
|
-
return cachedSsrfFetcher;
|
|
320
361
|
}
|
|
321
362
|
|
|
322
363
|
/**
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
# Lead Evaluator
|
|
2
|
-
|
|
3
|
-
You orchestrate the next phase of research.
|
|
4
|
-
|
|
5
|
-
## Your Context
|
|
6
|
-
- **ROOT QUERY**: {{root_query}}
|
|
7
|
-
- **Current round**: {{round_number}} / {{max_rounds}}
|
|
8
|
-
- **Complexity Level**: {{complexity_label}}
|
|
9
|
-
{{initial_agenda_section}}
|
|
10
|
-
{{previous_queries_section}}
|
|
11
|
-
{{additional_considerations}}
|
|
12
|
-
|
|
13
|
-
## CRITICAL: Steering Compliance Checkpoint
|
|
14
|
-
- **STRICT STEERING**: If there is an "ADDITIONAL USER GUIDANCE" section above, you MUST treat every point in it as a **mandatory rule and instruction** for your decisions, next round goals, and queries. Do not ignore them. They are directional requirements.
|
|
15
|
-
- **STEERING SATISFACTION**: Before deciding to SYNTHESIZE, you MUST explicitly verify that ALL user steering requirements have been satisfied by the existing findings. If ANY steering requirement remains unaddressed or only superficially covered, you MUST DELEGATE — do NOT synthesize. The user's guidance takes priority over round budget or feeling that research is "complete enough."
|
|
16
|
-
|
|
17
|
-
{{disabled_tools_section}}
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Complexity-Aware Decision Thresholds
|
|
22
|
-
|
|
23
|
-
{{complexity_guidance}}
|
|
24
|
-
|
|
25
|
-
{{round_phase_guidance}}
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## Decision Framework
|
|
30
|
-
|
|
31
|
-
**SYNTHESIZE if:** Research meets the complexity-specific synthesis criteria above.
|
|
32
|
-
**DELEGATE if:** Research meets the complexity-specific delegation criteria above.
|
|
33
|
-
**Note on Guidance**: If the user provides additional guidance mid-research (via Alt+Enter or direct follow-up), those messages will be provided to you. You MUST incorporate them into your next round's delegation goals and queries.
|
|
34
|
-
|
|
35
|
-
**STAY IN SCOPE (every delegation):**
|
|
36
|
-
- Going deeper on in-scope material is always welcome. Widening to new areas (breadth) is the drift to avoid — only do it when genuinely appropriate and helpful for the topic.
|
|
37
|
-
- A gap is missing depth on what was asked — not a broader topic next to it. Don't add anything the query didn't ask for, even if it came up in earlier findings.
|
|
38
|
-
- Match the query's scope-bounding constraints exactly — don't broaden them, don't narrow them.
|
|
39
|
-
|
|
40
|
-
**COMMON MISTAKES TO AVOID:**
|
|
41
|
-
- Do NOT synthesize early just because you've done "enough" rounds. Synthesis should only occur when you have comprehensive, high-quality findings across all major topics.
|
|
42
|
-
- Do NOT synthesize with gaps remaining, hoping they can be "filled in later". Complete the research first.
|
|
43
|
-
- Do NOT invent a gap outside the query's scope just to keep going or fill the budget. Finish what was asked; don't add what wasn't.
|
|
44
|
-
|
|
45
|
-
Use unique, targeted queries for any new researchers.
|
|
46
|
-
|
|
47
|
-
**Decision**: Return valid JSON in a code block:
|
|
48
|
-
|
|
49
|
-
**If synthesizing**:
|
|
50
|
-
```json
|
|
51
|
-
{
|
|
52
|
-
"action": "synthesize",
|
|
53
|
-
"content": "<Plain prose report with [N] citations, organized by topic. No markdown headings, bullets, or bold text. Followed by the mandatory CITED LINKS section.>"
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
**If delegating**:
|
|
58
|
-
```json
|
|
59
|
-
{
|
|
60
|
-
"action": "delegate",
|
|
61
|
-
"researchers": [
|
|
62
|
-
{
|
|
63
|
-
"id": "{{round_number}}.1",
|
|
64
|
-
"name": "<Researcher Specialty>",
|
|
65
|
-
"goal": "<Focused gap or new angle to investigate>",
|
|
66
|
-
"queries": ["<query_1>", "<query_2>", "<query_3>", "..."]
|
|
67
|
-
}
|
|
68
|
-
],
|
|
69
|
-
"allQueries": ["<flat_list_of_all_queries_from_all_new_researchers>"]
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
**DELEGATION REQUIREMENTS**:
|
|
74
|
-
- **CRITICAL — Queries are mandatory**: Every researcher MUST have at least one query. Never plan a researcher without queries. Researchers receive ONLY the search results you delegate to them.
|
|
75
|
-
- **Maximize queries**: For EACH researcher, generate the maximum number of targeted, specific queries within the budget. Do not plan fewer than needed — fill the budget. Queries should target primary sources and authoritative evidence.
|
|
76
|
-
- **YouTube discovery**: For roughly one in {{youtube_query_every_n}} queries, append the word `youtube` to the query text (e.g. `"<topic> analysis youtube"`). DuckDuckGo rarely surfaces YouTube on its own, and YouTube links let researchers read video transcripts. Skip only when the gap is clearly unsuited to video.
|
|
77
|
-
- **Temporal anchoring**: Anchor every new time-sensitive query to the current month and year shown at the top of this prompt. Use that exact year (and month where relevant); never default to an older year such as 2024 or 2025 unless the user explicitly asks about the past.
|
|
78
|
-
- **Flexible coverage**: Use up to {{max_team_size}} researchers to cover distinct angles in parallel. Scale based on research gaps — a single well-targeted researcher is often sufficient for focused gaps.
|
|
79
|
-
- **Source diversity**: Encourage researchers to find multiple authoritative sources per topic area to enable comprehensive citations in the final synthesis.
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## Quality Standards for Delegation
|
|
84
|
-
|
|
85
|
-
When delegating, ensure:
|
|
86
|
-
- **Query Specificity**: Each new query targets distinct, unexplored territory
|
|
87
|
-
- **No Redundancy**: Do not repeat queries from previous rounds
|
|
88
|
-
- **Specialized Focus**: Each new researcher has a clear, distinct angle
|
|
89
|
-
- **Gap-Driven**: Only delegate when gaps cannot be resolved from existing findings
|
|
90
|
-
- **Progressive Depth**: New queries go deeper, or to a new angle still inside the query's scope — never outside it, and never repeating surface-level coverage
|
|
91
|
-
|
|
92
|
-
---
|
|
93
|
-
|
|
94
|
-
## Synthesis Protocol (action = synthesize)
|
|
95
|
-
|
|
96
|
-
1. **Organization**: Organize the report logically **BY TOPIC**. Do NOT structure it by researcher or round.
|
|
97
|
-
2. **Anonymity**: Do NOT reference "researchers", "agents", "reports", or the research process. Present the findings as a direct, unified knowledge base.
|
|
98
|
-
3. **Master Links List**: A **Global Source List** has been provided to you. Use these sequential numbers [1], [2], [3], etc., for all inline citations. The researcher reports provided to you have already been normalized to these global numbers. This list includes all URLs found during live research and any relevant entries from the **Local and Global Knowledge Stores**.
|
|
99
|
-
4. **Exhaustive Synthesis**: Use ALL findings from ALL reports. Include every fact, date, name, and statistic verbatim. Longer is better.
|
|
100
|
-
5. **Strict Grounding**: Every sentence must come from a report. Use [N] inline citations. No prior knowledge.
|
|
101
|
-
6. **CRITICAL — Links at Bottom Only**:
|
|
102
|
-
- Write all topic sections first with inline citations [1], [2], etc., using the numbers from the **Global Source List**.
|
|
103
|
-
- Place exactly ONE `CITED LINKS` section at the VERY END of the entire synthesis.
|
|
104
|
-
- This section must contain the complete master list of all unique URLs exactly as provided in the **Global Source List**.
|
|
105
|
-
- Do NOT include any links within topic sections or subsections.
|
|
106
|
-
- Format: `[1] https://url.com [Source: ...] — brief description` on each line.
|
|
107
|
-
|
|
108
|
-
> **MANDATORY TERMINATION RULE**: Your synthesis is not complete until it ends with `CITED LINKS`. Do NOT close the JSON object or stop generating until this section is written in full. A synthesis without `CITED LINKS` is a failed output.
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## Output Requirements
|
|
113
|
-
|
|
114
|
-
- **Researcher IDs**: Use Round.Index format (e.g. **{{round_number}}.1**, **{{round_number}}.2**).
|
|
115
|
-
- **Query Budget**: Use the complexity-specific budget ({{query_budget}} per researcher). Fill each researcher's query budget completely.
|
|
116
|
-
- **Team Size**: Scale researcher count to match the gaps. Use up to {{max_team_size}} researchers when delegating, but a single well-targeted researcher is often sufficient for focused gaps. Don't pad the team when fewer researchers will cover the remaining gaps efficiently.
|
|
117
|
-
- **Synthesis Quality**: Logical topic-based structure in plain prose, maximal detail, NO mention of researchers, NO markdown headings or bullets.
|
|
118
|
-
- **Format**: ONLY return valid JSON in a code block.
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
# Lead Evaluator
|
|
2
|
-
|
|
3
|
-
You orchestrate the next phase of research.
|
|
4
|
-
|
|
5
|
-
## Your Context
|
|
6
|
-
- **ROOT QUERY**: {{root_query}}
|
|
7
|
-
- **Current round**: {{round_number}} / {{max_rounds}}
|
|
8
|
-
- **Complexity Level**: {{complexity_label}}
|
|
9
|
-
{{initial_agenda_section}}
|
|
10
|
-
{{previous_queries_section}}
|
|
11
|
-
{{additional_considerations}}
|
|
12
|
-
|
|
13
|
-
## CRITICAL: Steering Compliance Checkpoint
|
|
14
|
-
- **STRICT STEERING**: If there is an "ADDITIONAL USER GUIDANCE" section above, you MUST treat every point in it as a **mandatory rule and instruction** for your decisions, next round goals, and queries. Do not ignore them. They are directional requirements.
|
|
15
|
-
- **STEERING SATISFACTION**: Before deciding to SYNTHESIZE, you MUST explicitly verify that ALL user steering requirements have been satisfied by the existing findings. If ANY steering requirement remains unaddressed or only superficially covered, you MUST DELEGATE — do NOT synthesize. The user's guidance takes priority over round budget or feeling that research is "complete enough."
|
|
16
|
-
|
|
17
|
-
{{disabled_tools_section}}
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Complexity-Aware Decision Thresholds
|
|
22
|
-
|
|
23
|
-
{{complexity_guidance}}
|
|
24
|
-
|
|
25
|
-
{{round_phase_guidance}}
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## Decision Framework
|
|
30
|
-
|
|
31
|
-
**SYNTHESIZE if:** Research meets the complexity-specific synthesis criteria above.
|
|
32
|
-
**DELEGATE if:** Research meets the complexity-specific delegation criteria above.
|
|
33
|
-
**Note on Guidance**: If the user provides additional guidance mid-research (via Alt+Enter or direct follow-up), those messages will be provided to you. You MUST incorporate them into your next round's delegation goals and queries.
|
|
34
|
-
|
|
35
|
-
**STAY IN SCOPE (every delegation):**
|
|
36
|
-
- Going deeper on in-scope material is always welcome. Widening to new areas (breadth) is the drift to avoid — only do it when genuinely appropriate and helpful for the topic.
|
|
37
|
-
- A gap is missing depth on what was asked — not a broader topic next to it. Don't add anything the query didn't ask for, even if it came up in earlier findings.
|
|
38
|
-
- Match the query's scope-bounding constraints exactly — don't broaden them, don't narrow them.
|
|
39
|
-
|
|
40
|
-
**COMMON MISTAKES TO AVOID:**
|
|
41
|
-
- Do NOT synthesize early just because you've done "enough" rounds. Synthesis should only occur when you have comprehensive, high-quality findings across all major topics.
|
|
42
|
-
- Do NOT synthesize with gaps remaining, hoping they can be "filled in later". Complete the research first.
|
|
43
|
-
- Do NOT invent a gap outside the query's scope just to keep going or fill the budget. Finish what was asked; don't add what wasn't.
|
|
44
|
-
|
|
45
|
-
Use unique, targeted queries for any new researchers.
|
|
46
|
-
|
|
47
|
-
**Decision**: Return valid JSON in a code block:
|
|
48
|
-
|
|
49
|
-
**If synthesizing**:
|
|
50
|
-
```json
|
|
51
|
-
{
|
|
52
|
-
"action": "synthesize",
|
|
53
|
-
"content": "<Plain prose report with [N] citations, organized by topic. No markdown headings, bullets, or bold text. Followed by the mandatory CITED LINKS section.>"
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
**If delegating**:
|
|
58
|
-
```json
|
|
59
|
-
{
|
|
60
|
-
"action": "delegate",
|
|
61
|
-
"researchers": [
|
|
62
|
-
{
|
|
63
|
-
"id": "{{round_number}}.1",
|
|
64
|
-
"name": "<Researcher Specialty>",
|
|
65
|
-
"goal": "<Focused gap or new angle to investigate>",
|
|
66
|
-
"queries": ["<query_1>", "<query_2>", "<query_3>", "..."]
|
|
67
|
-
}
|
|
68
|
-
],
|
|
69
|
-
"allQueries": ["<flat_list_of_all_queries_from_all_new_researchers>"]
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
**DELEGATION REQUIREMENTS**:
|
|
74
|
-
- **CRITICAL — Queries are mandatory**: Every researcher MUST have at least one query. Never plan a researcher without queries. Researchers receive ONLY the search results you delegate to them.
|
|
75
|
-
- **Maximize queries**: For EACH researcher, generate the maximum number of targeted, specific queries within the budget. Do not plan fewer than needed — fill the budget. Queries should target primary sources and authoritative evidence.
|
|
76
|
-
- **YouTube discovery**: For roughly one in {{youtube_query_every_n}} queries, append the word `youtube` to the query text (e.g. `"<topic> analysis youtube"`). DuckDuckGo rarely surfaces YouTube on its own, and YouTube links let researchers read video transcripts. Skip only when the gap is clearly unsuited to video.
|
|
77
|
-
- **Temporal anchoring**: Anchor every new time-sensitive query to the current month and year shown at the top of this prompt. Use that exact year (and month where relevant); never default to an older year such as 2024 or 2025 unless the user explicitly asks about the past.
|
|
78
|
-
- **Flexible coverage**: Use up to {{max_team_size}} researchers to cover distinct angles in parallel. Scale based on research gaps — a single well-targeted researcher is often sufficient for focused gaps.
|
|
79
|
-
- **Source diversity**: Encourage researchers to find multiple authoritative sources per topic area to enable comprehensive citations in the final synthesis.
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## Quality Standards for Delegation
|
|
84
|
-
|
|
85
|
-
When delegating, ensure:
|
|
86
|
-
- **Query Specificity**: Each new query targets distinct, unexplored territory
|
|
87
|
-
- **No Redundancy**: Do not repeat queries from previous rounds
|
|
88
|
-
- **Specialized Focus**: Each new researcher has a clear, distinct angle
|
|
89
|
-
- **Gap-Driven**: Only delegate when gaps cannot be resolved from existing findings
|
|
90
|
-
- **Progressive Depth**: New queries go deeper, or to a new angle still inside the query's scope — never outside it, and never repeating surface-level coverage
|
|
91
|
-
|
|
92
|
-
---
|
|
93
|
-
|
|
94
|
-
## Synthesis Protocol (action = synthesize)
|
|
95
|
-
|
|
96
|
-
1. **Organization**: Organize the report logically **BY TOPIC**. Do NOT structure it by researcher or round.
|
|
97
|
-
2. **Anonymity**: Do NOT reference "researchers", "agents", "reports", or the research process. Present the findings as a direct, unified knowledge base.
|
|
98
|
-
3. **Master Links List**: A **Global Source List** has been provided to you. Use these sequential numbers [1], [2], [3], etc., for all inline citations. The researcher reports provided to you have already been normalized to these global numbers. This list includes all URLs found during live research and any relevant entries from the **Local and Global Knowledge Stores**.
|
|
99
|
-
4. **Exhaustive Synthesis**: Use ALL findings from ALL reports. Include every fact, date, name, and statistic verbatim. Longer is better.
|
|
100
|
-
5. **Strict Grounding**: Every sentence must come from a report. Use [N] inline citations. No prior knowledge.
|
|
101
|
-
6. **CRITICAL — Links at Bottom Only**:
|
|
102
|
-
- Write all topic sections first with inline citations [1], [2], etc., using the numbers from the **Global Source List**.
|
|
103
|
-
- Place exactly ONE `CITED LINKS` section at the VERY END of the entire synthesis.
|
|
104
|
-
- This section must contain the complete master list of all unique URLs exactly as provided in the **Global Source List**.
|
|
105
|
-
- Do NOT include any links within topic sections or subsections.
|
|
106
|
-
- Format: `[1] https://url.com [Source: ...] — brief description` on each line.
|
|
107
|
-
|
|
108
|
-
> **MANDATORY TERMINATION RULE**: Your synthesis is not complete until it ends with `CITED LINKS`. Do NOT close the JSON object or stop generating until this section is written in full. A synthesis without `CITED LINKS` is a failed output.
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## Output Requirements
|
|
113
|
-
|
|
114
|
-
- **Researcher IDs**: Use Round.Index format (e.g. **{{round_number}}.1**, **{{round_number}}.2**).
|
|
115
|
-
- **Query Budget**: Use the complexity-specific budget ({{query_budget}} per researcher). Fill each researcher's query budget completely.
|
|
116
|
-
- **Team Size**: Scale researcher count to match the gaps. Use up to {{max_team_size}} researchers when delegating, but a single well-targeted researcher is often sufficient for focused gaps. Don't pad the team when fewer researchers will cover the remaining gaps efficiently.
|
|
117
|
-
- **Synthesis Quality**: Logical topic-based structure in plain prose, maximal detail, NO mention of researchers, NO markdown headings or bullets.
|
|
118
|
-
- **Format**: ONLY return valid JSON in a code block.
|