Parallelisation as an Agentic Workflow
Parallelisation is one of the oldest tricks in computing. It turns out it works brilliantly with LLMs too.
The idea: break a task into independent, persona-based prompts, fire them all at once, then stitch the results together. You get faster responses and richer perspectives.
Weโll build this pattern using the @google/genai SDK, framed through a Star Wars scenario:
โWas the destruction of the Death Star justified?โ
Four personas (a Rebel pilot, an Imperial officer, a neutral citizen, and a droid analyst) will each answer simultaneously. Then a separate LLM call aggregates everything into one balanced summary.
What Is an Agentic Workflow?
An agentic workflow treats an LLM as a cooperative set of agents, each contributing to a more complex reasoning process. These agents can operate:
- Sequentially (e.g. prompt chaining)
- Via Routing
- Or, as weโll see here, in parallel
Parallelisation gives you two things:
- Lower latency (all agents think at once)
- Greater diversity (each prompt carries a unique voice or role)
This shines in multi-role decision making, creative brainstorming, and opinion synthesis.
Code Walkthrough: Multi-Perspective Reasoning
Weโll build a Node.js script that prompts four LLM โpersonasโ in parallel, collects their opinions, displays each response, then aggregates them into a single summary. The example here is playful, but the pattern transfers directly to real use cases: stakeholder debates, decomposing RAG queries into sub-queries, or running map-reduce style operations.
Setup
Weโll be using the official @google/genai SDK to interact with Google Gemini models via Node.js.
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
Step 1: The generateContent helper
This function sends a prompt to the LLM using Gemini 2.0 Flash and returns the response text. It also logs the prompt for visibility.
async function generateContent(prompt) {
const model = 'gemini-2.0-flash';
console.log(`\n๐ Prompt:\n${prompt}\n`);
const result = await ai.models.generateContent({ model, contents: prompt });
return result.text;
}
Step 2: Define our personas
Each perspective is represented by an object with a role and prompt. The roles cover diverse viewpoints to generate well-rounded answers. All prompts orbit the central question:
โWas the destruction of the Death Star justified?โ
You could further customise these personas by giving the LLM a more detailed character description.
const baseQuestion = 'Was the destruction of the Death Star justified?';
const personaPrompts = [
{
role: 'Rebel pilot',
emoji: '๐',
prompt: `As a Rebel pilot who fought in the Battle of Yavin, answer: ${baseQuestion}`,
},
{
role: 'Imperial officer',
emoji: '๐ก๏ธ',
prompt: `As an Imperial officer loyal to the Empire, answer: ${baseQuestion}`,
},
{
role: 'Neutral galactic citizen',
emoji: '๐',
prompt: `As a neutral galactic citizen with no allegiance, answer: ${baseQuestion}`,
},
{
role: 'Droid analyst',
emoji: '๐ค',
prompt: `As a logical droid analyst evaluating from an ethical and strategic standpoint, answer: ${baseQuestion}`,
},
];
Step 3: Run the LLM calls in parallel
We map over the persona prompts and fire all LLM requests concurrently using Promise.all().
const tasks = personaPrompts.map((p) => generateContent(p.prompt));
const responses = await Promise.all(tasks);
// We also time the whole process for benchmarking:
const startTime = Date.now();
// ... run tasks
const endTime = Date.now();
console.log(`\nโฑ๏ธ Time taken: ${(endTime - startTime) / 1000} seconds`);
Step 4: Display each perspective
Once weโve collected the responses, we output each one matched with its emoji and role:
console.log('\n--- Individual Perspectives ---');
responses.forEach((res, i) => {
const { role, emoji } = personaPrompts[i];
console.log(`${emoji} ${role}:\n${res}\n`);
});
This step isnโt strictly necessary, but it lets us inspect the individual responses before aggregation.
Step 5: Aggregate the viewpoints
We prepare a single prompt that combines all four responses and asks another LLM to synthesise the perspectives:
const aggregationInput = responses
.map(
(res, i) => `${personaPrompts[i].emoji} ${personaPrompts[i].role}:\n${res}`
)
.join('\n\n');
const aggregationPrompt = `Combine the following four perspectives into a thoughtful, balanced summary of the debate over whether the destruction of the Death Star was justified:\n\n${aggregationInput}`;
We then call a slightly more capable model (Gemini 2.5 Flash) to generate this summary. You could swap in a pro model for richer output:
const aggregationModel = 'gemini-2.5-flash-preview-04-17';
const summary = await ai.models.generateContent({
model: aggregationModel,
contents: aggregationPrompt,
});
console.log('\n๐ง --- Aggregated Summary ---');
console.log(`๐ Summary:\n${summary.text}\n`);
Hereโs what a typical run looks like:
Conclusion
This pattern shows how parallelisation in LLM workflows can simulate rich, multi-voice reasoning. Rather than leaning on a single model run, we treat each agent as an independent contributor, then aggregate their insights into something cohesive.
The same approach works well for:
- Multi-stakeholder feedback (e.g. HR, legal, product)
- Cross-role decision simulations
- Tone and perspective testing
- Ethical or philosophical debates
- AI-powered brainstorming with diverse โpersonasโ