Skip to content

Commit faf24aa

Browse files
committed
chore: rename example to 14- prefix and fix misleading shared memory prompts
The agent system prompts and task descriptions implied agents could explicitly read/write shared memory keys, but the framework handles this automatically. Simplified to match actual behavior.
1 parent d8c3808 commit faf24aa

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

examples/multi-perspective-code-review.ts renamed to examples/14-multi-perspective-code-review.ts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* Demonstrates:
55
* - Dependency chain: generator produces code, three reviewers depend on it
66
* - Parallel execution: security, performance, and style reviewers run concurrently
7-
* - Shared memory: generator writes code, reviewers read it and write feedback,
8-
* synthesizer reads all feedback and produces a unified report
7+
* - Shared memory: each agent's output is automatically stored and injected
8+
* into downstream agents' prompts by the framework
99
*
1010
* Flow:
1111
* generator → [security-reviewer, performance-reviewer, style-reviewer] (parallel) → synthesizer
1212
*
1313
* Run:
14-
* npx tsx examples/multi-perspective-code-review.ts
14+
* npx tsx examples/14-multi-perspective-code-review.ts
1515
*
1616
* Prerequisites:
1717
* ANTHROPIC_API_KEY env var must be set.
@@ -39,50 +39,45 @@ const generator: AgentConfig = {
3939
model: 'claude-sonnet-4-6',
4040
systemPrompt: `You are a Node.js backend developer. Given an API spec, write a complete
4141
Express route handler. Include imports, validation, database query, and error handling.
42-
Store the generated code in shared memory under the key "generated_code".
43-
Write only the code, no explanation. Keep it under 80 lines.`,
42+
Output only the code, no explanation. Keep it under 80 lines.`,
4443
maxTurns: 2,
4544
}
4645

4746
const securityReviewer: AgentConfig = {
4847
name: 'security-reviewer',
4948
model: 'claude-sonnet-4-6',
50-
systemPrompt: `You are a security reviewer. Read the code from shared memory key
51-
"generated_code" and check for OWASP top 10 vulnerabilities: SQL injection, XSS,
52-
broken authentication, sensitive data exposure, etc. Write your findings as a
53-
markdown checklist. Store your review in shared memory under "security_review".
49+
systemPrompt: `You are a security reviewer. Review the code provided in context and check
50+
for OWASP top 10 vulnerabilities: SQL injection, XSS, broken authentication,
51+
sensitive data exposure, etc. Write your findings as a markdown checklist.
5452
Keep it to 150-200 words.`,
5553
maxTurns: 2,
5654
}
5755

5856
const performanceReviewer: AgentConfig = {
5957
name: 'performance-reviewer',
6058
model: 'claude-sonnet-4-6',
61-
systemPrompt: `You are a performance reviewer. Read the code from shared memory key
62-
"generated_code" and check for N+1 queries, memory leaks, blocking calls, missing
63-
connection pooling, and inefficient patterns. Write your findings as a markdown
64-
checklist. Store your review in shared memory under "performance_review".
59+
systemPrompt: `You are a performance reviewer. Review the code provided in context and check
60+
for N+1 queries, memory leaks, blocking calls, missing connection pooling, and
61+
inefficient patterns. Write your findings as a markdown checklist.
6562
Keep it to 150-200 words.`,
6663
maxTurns: 2,
6764
}
6865

6966
const styleReviewer: AgentConfig = {
7067
name: 'style-reviewer',
7168
model: 'claude-sonnet-4-6',
72-
systemPrompt: `You are a code style reviewer. Read the code from shared memory key
73-
"generated_code" and check naming conventions, function structure, readability,
74-
error message clarity, and consistency. Write your findings as a markdown checklist.
75-
Store your review in shared memory under "style_review".
69+
systemPrompt: `You are a code style reviewer. Review the code provided in context and check
70+
naming conventions, function structure, readability, error message clarity, and
71+
consistency. Write your findings as a markdown checklist.
7672
Keep it to 150-200 words.`,
7773
maxTurns: 2,
7874
}
7975

8076
const synthesizer: AgentConfig = {
8177
name: 'synthesizer',
8278
model: 'claude-sonnet-4-6',
83-
systemPrompt: `You are a lead engineer synthesizing code review feedback. Read all
84-
reviews from shared memory (security_review, performance_review, style_review) and
85-
the original code (generated_code). Produce a unified report with:
79+
systemPrompt: `You are a lead engineer synthesizing code review feedback. Review all
80+
the feedback and original code provided in context. Produce a unified report with:
8681
8782
1. Critical issues (must fix before merge)
8883
2. Recommended improvements (should fix)
@@ -124,30 +119,30 @@ const team = orchestrator.createTeam('code-review-team', {
124119
const tasks = [
125120
{
126121
title: 'Generate code',
127-
description: `Write a Node.js Express route handler for this API spec:\n\n${API_SPEC}\n\nStore the complete code in shared memory as "generated_code".`,
122+
description: `Write a Node.js Express route handler for this API spec:\n\n${API_SPEC}`,
128123
assignee: 'generator',
129124
},
130125
{
131126
title: 'Security review',
132-
description: 'Read "generated_code" from shared memory and perform a security review. Store findings in shared memory as "security_review".',
127+
description: 'Review the generated code for security vulnerabilities.',
133128
assignee: 'security-reviewer',
134129
dependsOn: ['Generate code'],
135130
},
136131
{
137132
title: 'Performance review',
138-
description: 'Read "generated_code" from shared memory and perform a performance review. Store findings in shared memory as "performance_review".',
133+
description: 'Review the generated code for performance issues.',
139134
assignee: 'performance-reviewer',
140135
dependsOn: ['Generate code'],
141136
},
142137
{
143138
title: 'Style review',
144-
description: 'Read "generated_code" from shared memory and perform a style review. Store findings in shared memory as "style_review".',
139+
description: 'Review the generated code for style and readability.',
145140
assignee: 'style-reviewer',
146141
dependsOn: ['Generate code'],
147142
},
148143
{
149144
title: 'Synthesize feedback',
150-
description: 'Read all reviews (security_review, performance_review, style_review) and the original generated_code from shared memory. Produce a unified, prioritized action item report.',
145+
description: 'Synthesize all review feedback and the original code into a unified, prioritized action item report.',
151146
assignee: 'synthesizer',
152147
dependsOn: ['Security review', 'Performance review', 'Style review'],
153148
},

0 commit comments

Comments
 (0)