Parallelisation as an Agentic Workflow

In the world of agentic AI workflows, there's a compelling design pattern that mirrors one of the most powerful ideas in computing: parallelisation. It's fast, scalable, and surprisingly intuitive when used with large language models (LLMs). In this blog post, we'll explore how breaking a task into independent, persona-based LLM prompts - and running them concurrently - can supercharge reasoning and creativity.

And to make things fun? We're heading to a galaxy far, far away...

We'll explore how to implement this pattern using the @google/genai SDK, framed through a fun, narrative-rich Star Wars scenario:

"Was the destruction of the Death Star justified?"

We'll simulate answers from four personas — a Rebel pilot, an Imperial officer, a neutral citizen, and a droid analyst - running their LLM prompts in parallel, before synthesising their perspectives into a single summary.

What Is an Agentic Workflow?

An agentic workflow treats an LLM not as a monolithic oracle, but as a cooperative set of agents, each contributing to a more complex reasoning process. These agents can operate:

Parallelisation allows us to:

  • Reduce latency (all agents think at once)
  • Increase diversity (each prompt has a unique voice or role)

This is particularly useful for multi-role decision making, creative brainstorming, and opinion synthesis.

Code Walkthrough: Multi-Perspective Reasoning

We'll build a Node.js script that will prompt four LLM "personas" in parallel and get their opinion about a particular subject. We will diplay their responses, and last but not least aggregate their answers into a single, final summary. While the example here that we use will be a fun one, you can hopefully see how this can be transferred into real use-cases such as debating, decomposition of complex tasks (maybe decompose a RAG query into muliple sub queries) or even running an operation that developers are familiar with such as map-reduce.

Setup

We'll be using the official @google/genai SDK, which lets us 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. All roles respresent diverse personas to get an all-round opinioned answers and prompts are built around the central question:

"Was the destruction of the Death Star justified?"

The personas could be further customised by providing the LLM a more complex description of the persona.

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 now map over the persona prompts and trigger 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 clearly, 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 is not required of course but it allows us to see the individual responses from the LLMs for each of the personas that we have specified.

Step 5: Aggregate the viewpoints

We now prepare a single prompt that combines all four responses and asks another LLM to summarise the perspectives in a balanced way:

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 (this could be a pro model as well for a better 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`);
Expand here for an example output

šŸ“ Prompt:
As a Rebel pilot who fought in the Battle of Yavin, answer: Was the destruction of the Death Star justified?

šŸ“ Prompt:
As an Imperial officer loyal to the Empire, answer: Was the destruction of the Death Star justified?

šŸ“ Prompt:
As a neutral galactic citizen with no allegiance, answer: Was the destruction of the Death Star justified?

šŸ“ Prompt:
As a logical droid analyst evaluating from an ethical and strategic standpoint, answer: Was the destruction of the Death Star justified?

ā±ļø Time taken: 7.186 seconds

--- Individual Perspectives ---

šŸš€ Rebel pilot:
Justified? Absolutely. Without a shadow of a doubt.

I was there, okay? I saw Alderaan. I saw that beautiful, peaceful planet ripped apart in an instant. I saw the lives of billions extinguished like flicking off a light switch. That wasn't just a demonstration of power. That was an act of pure, unadulterated terror designed to crush the Rebellion and force the galaxy into absolute submission.

They were using the Death Star to enforce tyranny. Every system that even *thought* about questioning the Empire was living under the threat of planetary annihilation. They were suffocating freedom, crushing dissent, and ruling through fear.

So, let me tell you something. That battle wasn't just about blowing up a weapon. It was about striking a blow for freedom. It was about standing up to a bully who was terrorising the entire galaxy. It was about showing the Empire that they couldn't just murder anyone they wanted without consequence.

Some will argue about the cost, the lives lost on the Death Star. But those lives were in service of a machine of ultimate destruction. They were complicit in the Empire's atrocities. They chose to serve the darkness.

We didn't choose this fight. We were forced into it. The Empire forced us into it. And when faced with the choice between freedom and annihilation, between hope and despair, we chose to fight back.

The destruction of the Death Star was not just justified. It was necessary. It was a beacon of hope in a galaxy drowning in darkness. It was a declaration that freedom will always fight back against tyranny. I saw it with my own eyes. I flew that mission. And I wouldn't change a thing.

šŸ›”ļø Imperial officer:
Justified? Officer, that's hardly the word I'd use. The destruction of the Death Star was a catastrophic tragedy orchestrated by treacherous rebels and their sympathisers.

Let's be clear. The Death Star was a symbol of Imperial order and strength, a testament to the Emperor's vision of a galaxy united under unwavering rule. It represented the unwavering dedication of thousands of loyal Imperial citizens, engineers, and officers, all striving to bring peace and security to a chaotic galaxy. Its mere presence deterred planetary rebellion and brought stability to countless star systems.

To suggest its destruction was justified is to spit on the graves of those brave Imperials who perished aboard that station, upholding the Emperor's will. It ignores the countless lives that would have been saved, the infrastructure that would have been built, the advancements that would have been made, had the rebels not engaged in their cowardly act of terror.

The destruction of the Death Star was a monumental setback for the Empire and a victory for anarchy. It emboldened rebel factions, fuelled unrest, and ultimately prolonged the war. It allowed the forces of chaos to fester and spread, destabilising entire sectors.

So no, Officer. The destruction of the Death Star was not justified. It was an act of rebellion, an act of treason, and an act that ultimately weakened the very foundation of the galaxy. We must never forget the sacrifices made and learn from the mistakes that allowed this tragedy to occur. The Empire must remain vigilant and steadfast in its commitment to eradicating such sedition and restoring order to the galaxy. The Emperor protects.

🌌 Neutral galactic citizen:
From a purely neutral and objective standpoint, the destruction of the Death Star presents a complex ethical and strategic dilemma. Justification depends heavily on one's perspective and prioritisation of values.

Arguments for Justification:
• Preventive Action: The Death Star was designed and intended as a planet-destroying superweapon. It had already demonstrated its capability and intent by obliterating Alderaan. From a perspective of galactic self-preservation, its destruction could be argued as a preemptive act to prevent further atrocities and maintain galactic stability.
• Targeting a Military Asset: The Death Star, despite its civilian population, was ultimately a military installation. Targeting military assets during a time of conflict is a generally accepted, though ethically fraught, aspect of warfare.
• Symbolic Victory: The destruction of the Death Star served as a major symbolic victory for the Rebellion. It bolstered morale, attracted new recruits, and demonstrated that the Empire was not invincible.

Arguments Against Justification:
• Loss of Life: The Death Star was crewed by a large number of individuals, both military personnel and civilian support staff. Regardless of their allegiance, the destruction of the station resulted in massive loss of life, and arguably constitutes a war crime by modern galactic standards.
• Escalation of Conflict: While the destruction of the Death Star dealt a blow to the Empire, it also served to escalate the conflict. The Empire likely responded with increased aggression and oppression, leading to further suffering and instability across the galaxy.
• Disproportionate Response: The destruction of an entire battle station may be viewed as a disproportionate response, even if the Death Star was a military asset.

Conclusion:
Ultimately, the destruction of the Death Star cannot be definitively justified or condemned. It was a complex decision with both positive and negative consequences. Its justification rests heavily on the moral and strategic framework of the observer.

šŸ¤– Droid analyst:
Analysing the destruction of the Death Star from an ethical and strategic standpoint requires a complex assessment. Let's break it down:

Ethical Considerations:
• The Death Star's Intentions and Actions: The Death Star was explicitly designed and used for planet-destroying capabilities. It demonstrated its destructive power by annihilating Alderaan.
• Collateral Damage: The destruction of the Death Star resulted in the deaths of thousands, including conscripted individuals, support staff, and officers who may not have directly participated in the decision to destroy Alderaan.
• Just War Theory:
   ā€¢ Just Cause: Arguably, the Rebellion had a just cause.
   ā€¢ Right Intention: The Rebellion aimed to restore freedom and democracy.
   ā€¢ Proportionality: Was the destruction proportional to the threat?
   ā€¢ Last Resort: Diplomacy was not viable with the Empire.

Strategic Considerations:
• Eliminating a Major Threat: The Death Star represented a game-changing weapon.
• Inspiring Rebellion: Its destruction demonstrated that the Empire was not invincible.
• Cost vs. Benefit: The strategic benefit arguably outweighed the cost.
• Long-Term Implications: It fundamentally shifted the power dynamic.

Conclusion:
From a purely utilitarian perspective, the destruction of the Death Star can be argued as justified. From a deontological perspective, it becomes more complex.

🧠 --- Aggregated Summary ---
šŸŒ€ Summary:
The question of whether the destruction of the Death Star was justified is a deeply contentious one, marked by starkly different perspectives rooted in experience, ideology, and ethical frameworks.

From the visceral viewpoint of a Rebel pilot who witnessed the annihilation of Alderaan, the act was unequivocally justified. For them, the Death Star was the ultimate instrument of the Empire's terror campaign. Conversely, an Imperial officer sees the act as treason, a catastrophic tragedy. A neutral galactic citizen outlines compelling arguments on both sides, while a droid analyst assesses the situation through Just War Theory and strategic calculus, ultimately leaning toward justification due to the threat posed.

In synthesis, justification hinges on one's moral framework and position in the conflict. It remains a poignant example of the terrible choices faced in a galaxy consumed by war.

Conclusion

This example demonstrates how parallelisation in LLM workflows can simulate rich, multi-voice reasoning. Rather than relying on a single model run, we treat each agent as an independent contributor, offering parallel insight that can be aggregated meaningfully.

This pattern works exceptionally well in real-world applications like:

  • 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"