Skip to content

Commit 54bfe2e

Browse files
committed
fix: address review feedback on research aggregation example
- Fix handleProgress: use underscore event types (task_start/task_complete) and correct property names (event.task/event.agent) per OrchestratorEvent - Remove Task[] annotation (Task requires id, status, createdAt, updatedAt) - Rename 13-research-aggregation.ts to 14-research-aggregation.ts - Remove shared memory key references from prompts (framework handles this) - Add header note differentiating from example 07 (runTasks vs AgentPool)
1 parent 34ca860 commit 54bfe2e

1 file changed

Lines changed: 24 additions & 22 deletions

File tree

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
/**
2-
* Example 13 — Multi-Source Research Aggregation
2+
* Example 14 — Multi-Source Research Aggregation
33
*
4-
* Demonstrates:
4+
* Demonstrates runTasks() with explicit dependency chains:
55
* - Parallel execution: three analyst agents research the same topic independently
6-
* - Dependency chain: synthesizer waits for all analysts to finish
7-
* - Shared memory: analysts write findings, synthesizer reads and cross-references
6+
* - Dependency chain via dependsOn: synthesizer waits for all analysts to finish
7+
* - Automatic shared memory: agent output flows to downstream agents via the framework
8+
*
9+
* Compare with example 07 (fan-out-aggregate) which uses AgentPool.runParallel()
10+
* for the same 3-analysts + synthesizer pattern. This example shows the runTasks()
11+
* API with explicit dependsOn declarations instead.
812
*
913
* Flow:
1014
* [technical-analyst, market-analyst, community-analyst] (parallel) → synthesizer
1115
*
1216
* Run:
13-
* npx tsx examples/13-research-aggregation.ts
17+
* npx tsx examples/14-research-aggregation.ts
1418
*
1519
* Prerequisites:
1620
* ANTHROPIC_API_KEY env var must be set.
1721
*/
1822

1923
import { OpenMultiAgent } from '../src/index.js'
20-
import type { AgentConfig, OrchestratorEvent, Task } from '../src/types.js'
24+
import type { AgentConfig, OrchestratorEvent } from '../src/types.js'
2125

2226
// ---------------------------------------------------------------------------
2327
// Topic
@@ -34,8 +38,7 @@ const technicalAnalyst: AgentConfig = {
3438
model: 'claude-sonnet-4-6',
3539
systemPrompt: `You are a technical analyst. Given a topic, research its technical
3640
capabilities, limitations, performance characteristics, and architectural patterns.
37-
Write your findings as structured markdown. Store your analysis in shared memory
38-
under the key "technical_findings". Keep it to 200-300 words.`,
41+
Write your findings as structured markdown. Keep it to 200-300 words.`,
3942
maxTurns: 2,
4043
}
4144

@@ -44,8 +47,7 @@ const marketAnalyst: AgentConfig = {
4447
model: 'claude-sonnet-4-6',
4548
systemPrompt: `You are a market analyst. Given a topic, research industry adoption
4649
rates, key companies using the technology, market size estimates, and competitive
47-
landscape. Write your findings as structured markdown. Store your analysis in
48-
shared memory under the key "market_findings". Keep it to 200-300 words.`,
50+
landscape. Write your findings as structured markdown. Keep it to 200-300 words.`,
4951
maxTurns: 2,
5052
}
5153

@@ -55,7 +57,6 @@ const communityAnalyst: AgentConfig = {
5557
systemPrompt: `You are a developer community analyst. Given a topic, research
5658
developer sentiment, ecosystem maturity, learning resources, community size,
5759
and conference/meetup activity. Write your findings as structured markdown.
58-
Store your analysis in shared memory under the key "community_findings".
5960
Keep it to 200-300 words.`,
6061
maxTurns: 2,
6162
}
@@ -64,9 +65,10 @@ const synthesizer: AgentConfig = {
6465
name: 'synthesizer',
6566
model: 'claude-sonnet-4-6',
6667
systemPrompt: `You are a research director who synthesizes multiple analyst reports
67-
into a single cohesive document. Read all findings from shared memory, then:
68+
into a single cohesive document. You will receive all prior analyst outputs
69+
automatically. Then:
6870
69-
1. Cross-reference claims across reports flag agreements and contradictions
71+
1. Cross-reference claims across reports - flag agreements and contradictions
7072
2. Identify the 3 most important insights
7173
3. Produce a structured report with: Executive Summary, Key Findings,
7274
Areas of Agreement, Open Questions, and Recommendation
@@ -80,11 +82,11 @@ Keep the final report to 300-400 words.`,
8082
// ---------------------------------------------------------------------------
8183

8284
function handleProgress(event: OrchestratorEvent): void {
83-
if (event.type === 'task:start') {
84-
console.log(` [START] ${event.taskTitle}${event.agentName}`)
85+
if (event.type === 'task_start') {
86+
console.log(` [START] ${event.task ?? ''}${event.agent ?? ''}`)
8587
}
86-
if (event.type === 'task:complete') {
87-
console.log(` [DONE] ${event.taskTitle} (${event.success ? 'OK' : 'FAIL'})`)
88+
if (event.type === 'task_complete') {
89+
console.log(` [DONE] ${event.task ?? ''}`)
8890
}
8991
}
9092

@@ -103,25 +105,25 @@ const team = orchestrator.createTeam('research-team', {
103105
// Tasks — three analysts run in parallel, synthesizer depends on all three
104106
// ---------------------------------------------------------------------------
105107

106-
const tasks: Task[] = [
108+
const tasks = [
107109
{
108110
title: 'Technical analysis',
109-
description: `Research the technical aspects of ${TOPIC}. Focus on capabilities, limitations, performance, and architecture. Store findings in shared memory as "technical_findings".`,
111+
description: `Research the technical aspects of ${TOPIC}. Focus on capabilities, limitations, performance, and architecture.`,
110112
assignee: 'technical-analyst',
111113
},
112114
{
113115
title: 'Market analysis',
114-
description: `Research the market landscape for ${TOPIC}. Focus on adoption rates, key players, market size, and competition. Store findings in shared memory as "market_findings".`,
116+
description: `Research the market landscape for ${TOPIC}. Focus on adoption rates, key players, market size, and competition.`,
115117
assignee: 'market-analyst',
116118
},
117119
{
118120
title: 'Community analysis',
119-
description: `Research the developer community around ${TOPIC}. Focus on sentiment, ecosystem maturity, learning resources, and community activity. Store findings in shared memory as "community_findings".`,
121+
description: `Research the developer community around ${TOPIC}. Focus on sentiment, ecosystem maturity, learning resources, and community activity.`,
120122
assignee: 'community-analyst',
121123
},
122124
{
123125
title: 'Synthesize report',
124-
description: `Read all analyst findings from shared memory (technical_findings, market_findings, community_findings). Cross-reference claims, identify key insights, flag contradictions, and produce a unified research report.`,
126+
description: `Cross-reference all analyst findings, identify key insights, flag contradictions, and produce a unified research report.`,
125127
assignee: 'synthesizer',
126128
dependsOn: ['Technical analysis', 'Market analysis', 'Community analysis'],
127129
},

0 commit comments

Comments
 (0)