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.
This commit is contained in:
parent
d8c3808851
commit
faf24aaffa
|
|
@ -4,14 +4,14 @@
|
||||||
* Demonstrates:
|
* Demonstrates:
|
||||||
* - Dependency chain: generator produces code, three reviewers depend on it
|
* - Dependency chain: generator produces code, three reviewers depend on it
|
||||||
* - Parallel execution: security, performance, and style reviewers run concurrently
|
* - Parallel execution: security, performance, and style reviewers run concurrently
|
||||||
* - Shared memory: generator writes code, reviewers read it and write feedback,
|
* - Shared memory: each agent's output is automatically stored and injected
|
||||||
* synthesizer reads all feedback and produces a unified report
|
* into downstream agents' prompts by the framework
|
||||||
*
|
*
|
||||||
* Flow:
|
* Flow:
|
||||||
* generator → [security-reviewer, performance-reviewer, style-reviewer] (parallel) → synthesizer
|
* generator → [security-reviewer, performance-reviewer, style-reviewer] (parallel) → synthesizer
|
||||||
*
|
*
|
||||||
* Run:
|
* Run:
|
||||||
* npx tsx examples/multi-perspective-code-review.ts
|
* npx tsx examples/14-multi-perspective-code-review.ts
|
||||||
*
|
*
|
||||||
* Prerequisites:
|
* Prerequisites:
|
||||||
* ANTHROPIC_API_KEY env var must be set.
|
* ANTHROPIC_API_KEY env var must be set.
|
||||||
|
|
@ -39,18 +39,16 @@ const generator: AgentConfig = {
|
||||||
model: 'claude-sonnet-4-6',
|
model: 'claude-sonnet-4-6',
|
||||||
systemPrompt: `You are a Node.js backend developer. Given an API spec, write a complete
|
systemPrompt: `You are a Node.js backend developer. Given an API spec, write a complete
|
||||||
Express route handler. Include imports, validation, database query, and error handling.
|
Express route handler. Include imports, validation, database query, and error handling.
|
||||||
Store the generated code in shared memory under the key "generated_code".
|
Output only the code, no explanation. Keep it under 80 lines.`,
|
||||||
Write only the code, no explanation. Keep it under 80 lines.`,
|
|
||||||
maxTurns: 2,
|
maxTurns: 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
const securityReviewer: AgentConfig = {
|
const securityReviewer: AgentConfig = {
|
||||||
name: 'security-reviewer',
|
name: 'security-reviewer',
|
||||||
model: 'claude-sonnet-4-6',
|
model: 'claude-sonnet-4-6',
|
||||||
systemPrompt: `You are a security reviewer. Read the code from shared memory key
|
systemPrompt: `You are a security reviewer. Review the code provided in context and check
|
||||||
"generated_code" and check for OWASP top 10 vulnerabilities: SQL injection, XSS,
|
for OWASP top 10 vulnerabilities: SQL injection, XSS, broken authentication,
|
||||||
broken authentication, sensitive data exposure, etc. Write your findings as a
|
sensitive data exposure, etc. Write your findings as a markdown checklist.
|
||||||
markdown checklist. Store your review in shared memory under "security_review".
|
|
||||||
Keep it to 150-200 words.`,
|
Keep it to 150-200 words.`,
|
||||||
maxTurns: 2,
|
maxTurns: 2,
|
||||||
}
|
}
|
||||||
|
|
@ -58,10 +56,9 @@ Keep it to 150-200 words.`,
|
||||||
const performanceReviewer: AgentConfig = {
|
const performanceReviewer: AgentConfig = {
|
||||||
name: 'performance-reviewer',
|
name: 'performance-reviewer',
|
||||||
model: 'claude-sonnet-4-6',
|
model: 'claude-sonnet-4-6',
|
||||||
systemPrompt: `You are a performance reviewer. Read the code from shared memory key
|
systemPrompt: `You are a performance reviewer. Review the code provided in context and check
|
||||||
"generated_code" and check for N+1 queries, memory leaks, blocking calls, missing
|
for N+1 queries, memory leaks, blocking calls, missing connection pooling, and
|
||||||
connection pooling, and inefficient patterns. Write your findings as a markdown
|
inefficient patterns. Write your findings as a markdown checklist.
|
||||||
checklist. Store your review in shared memory under "performance_review".
|
|
||||||
Keep it to 150-200 words.`,
|
Keep it to 150-200 words.`,
|
||||||
maxTurns: 2,
|
maxTurns: 2,
|
||||||
}
|
}
|
||||||
|
|
@ -69,10 +66,9 @@ Keep it to 150-200 words.`,
|
||||||
const styleReviewer: AgentConfig = {
|
const styleReviewer: AgentConfig = {
|
||||||
name: 'style-reviewer',
|
name: 'style-reviewer',
|
||||||
model: 'claude-sonnet-4-6',
|
model: 'claude-sonnet-4-6',
|
||||||
systemPrompt: `You are a code style reviewer. Read the code from shared memory key
|
systemPrompt: `You are a code style reviewer. Review the code provided in context and check
|
||||||
"generated_code" and check naming conventions, function structure, readability,
|
naming conventions, function structure, readability, error message clarity, and
|
||||||
error message clarity, and consistency. Write your findings as a markdown checklist.
|
consistency. Write your findings as a markdown checklist.
|
||||||
Store your review in shared memory under "style_review".
|
|
||||||
Keep it to 150-200 words.`,
|
Keep it to 150-200 words.`,
|
||||||
maxTurns: 2,
|
maxTurns: 2,
|
||||||
}
|
}
|
||||||
|
|
@ -80,9 +76,8 @@ Keep it to 150-200 words.`,
|
||||||
const synthesizer: AgentConfig = {
|
const synthesizer: AgentConfig = {
|
||||||
name: 'synthesizer',
|
name: 'synthesizer',
|
||||||
model: 'claude-sonnet-4-6',
|
model: 'claude-sonnet-4-6',
|
||||||
systemPrompt: `You are a lead engineer synthesizing code review feedback. Read all
|
systemPrompt: `You are a lead engineer synthesizing code review feedback. Review all
|
||||||
reviews from shared memory (security_review, performance_review, style_review) and
|
the feedback and original code provided in context. Produce a unified report with:
|
||||||
the original code (generated_code). Produce a unified report with:
|
|
||||||
|
|
||||||
1. Critical issues (must fix before merge)
|
1. Critical issues (must fix before merge)
|
||||||
2. Recommended improvements (should fix)
|
2. Recommended improvements (should fix)
|
||||||
|
|
@ -124,30 +119,30 @@ const team = orchestrator.createTeam('code-review-team', {
|
||||||
const tasks = [
|
const tasks = [
|
||||||
{
|
{
|
||||||
title: 'Generate code',
|
title: 'Generate code',
|
||||||
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".`,
|
description: `Write a Node.js Express route handler for this API spec:\n\n${API_SPEC}`,
|
||||||
assignee: 'generator',
|
assignee: 'generator',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Security review',
|
title: 'Security review',
|
||||||
description: 'Read "generated_code" from shared memory and perform a security review. Store findings in shared memory as "security_review".',
|
description: 'Review the generated code for security vulnerabilities.',
|
||||||
assignee: 'security-reviewer',
|
assignee: 'security-reviewer',
|
||||||
dependsOn: ['Generate code'],
|
dependsOn: ['Generate code'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Performance review',
|
title: 'Performance review',
|
||||||
description: 'Read "generated_code" from shared memory and perform a performance review. Store findings in shared memory as "performance_review".',
|
description: 'Review the generated code for performance issues.',
|
||||||
assignee: 'performance-reviewer',
|
assignee: 'performance-reviewer',
|
||||||
dependsOn: ['Generate code'],
|
dependsOn: ['Generate code'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Style review',
|
title: 'Style review',
|
||||||
description: 'Read "generated_code" from shared memory and perform a style review. Store findings in shared memory as "style_review".',
|
description: 'Review the generated code for style and readability.',
|
||||||
assignee: 'style-reviewer',
|
assignee: 'style-reviewer',
|
||||||
dependsOn: ['Generate code'],
|
dependsOn: ['Generate code'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Synthesize feedback',
|
title: 'Synthesize feedback',
|
||||||
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.',
|
description: 'Synthesize all review feedback and the original code into a unified, prioritized action item report.',
|
||||||
assignee: 'synthesizer',
|
assignee: 'synthesizer',
|
||||||
dependsOn: ['Security review', 'Performance review', 'Style review'],
|
dependsOn: ['Security review', 'Performance review', 'Style review'],
|
||||||
},
|
},
|
||||||
Loading…
Reference in New Issue