Skip to content
Engineering

Parallel Execution, Loop Steps, and Conditions: Workflow Patterns That Actually Matter

JieGou workflows support eight step types: recipe, condition, loop, parallel, approval, write-to-KB, handoff, and browser action. Here's when to use each one and how to combine them effectively.

JT
JieGou Team
· · 9 min read

A workflow that’s just a linear chain of recipes — step 1 feeds step 2 feeds step 3 — handles many use cases. But real business processes branch, loop, run things simultaneously, require human sign-off, and interact with external systems. JieGou’s eight step types let you model these patterns.

Recipe steps: the building block

A recipe step runs a single AI recipe with mapped inputs and structured output. It’s the fundamental unit of work in any workflow.

When to use: Every time you need the AI to do something — extract data, generate content, analyze input, classify items.

Key design choice: Input mappings. Each input field maps to a source: a static value, a workflow-level input, a previous step’s output, or a loop item. The mapping step_1.company_overview means “take the company_overview field from step 1’s output.” This is how data flows between steps.

Tip: Use the cheapest model that produces acceptable output. Don’t use Opus for a simple formatting step that Haiku handles fine.

Condition steps: branching logic

A condition step evaluates a value against a comparison and branches into thenSteps or elseSteps.

Eight operators are available: equals, not_equals, contains, not_contains, greater_than, less_than, is_empty, is_not_empty.

When to use:

  • Route qualified vs. unqualified leads to different paths
  • Handle errors differently based on severity
  • Skip steps when data is missing
  • Gate expensive steps behind a quality check

Example — Invoice processing:

Step 1: Extract invoice data
Step 2: Check discrepancies
Step 3: Condition (discrepancy_count > 0)
  Then: Route to manager approval
  Else: Auto-file the invoice

The condition checks step_2.discrepancy_count against 0 using greater_than. No AI call needed — it’s pure logic.

Tip: Use conditions after extraction steps to validate that the AI actually found the data you need. Checking is_not_empty on a critical field prevents downstream steps from running on incomplete data.

Loop steps: processing collections

A loop step iterates over a collection, running its nested loopSteps for each item. The collection source is a field from a previous step’s output — typically an array.

When to use:

  • Process each candidate in a hiring batch
  • Analyze each line item in an invoice
  • Generate content for each channel from a content plan
  • Review each clause in a contract

Example — Batch candidate screening:

Step 1: Parse candidate list → outputs candidates[]
Step 2: Loop over candidates
  Step 2.1: Screen resume (input mapped to loop_item)
  Step 2.2: Generate interview questions (if qualified)

Each iteration gets the current item via loop_item mapping. The loop aggregates all iteration outputs into a single result.

Tip: Keep loop bodies lean. If you’re running 50 iterations and each has 3 recipe steps, that’s 150 AI calls. Use the cheapest effective model inside loops.

Parallel steps: concurrent execution

A parallel step runs multiple branches simultaneously using Promise.allSettled(). Each branch is an independent sequence of steps. All branches start at the same time; the parallel step completes when all branches finish (or fail).

When to use:

  • Generate content for multiple channels simultaneously
  • Run independent analyses that don’t depend on each other
  • Process multiple data sources at once
  • Speed up workflows where steps have no dependencies

Example — Multi-channel content generation:

Step 1: Analyze blog post
Step 2: Parallel
  Branch A: Generate LinkedIn posts
  Branch B: Generate Twitter thread
  Branch C: Generate newsletter section
  Branch D: Generate email campaign copy

Branches A through D run concurrently. Each gets a snapshot of the output map at the time the parallel step starts — they can read from previous steps but can’t see each other’s outputs during execution.

Key behavior: If Branch B fails, Branches A, C, and D continue and complete normally. Promise.allSettled means one failure doesn’t kill the rest. After the parallel step, you can check which branches succeeded.

Tip: Parallel steps are ideal when you need the same input processed in multiple ways. The speed improvement is significant — four concurrent branches complete in roughly the same time as one sequential step.

Approval steps: human checkpoints

An approval step pauses the workflow and sends a notification (typically email) to an approver. The workflow resumes only when the approver takes action: approve, reject, or provide input.

When to use:

  • Before sending customer-facing content
  • Before executing financial transactions
  • After AI-generated analysis that informs a business decision
  • Any point where human judgment is required before proceeding

Example — Content publishing pipeline:

Step 1: Generate blog post draft
Step 2: Approval (content manager reviews)
Step 3: Generate social media posts from approved draft
Step 4: Approval (marketing lead reviews final package)

Two approval gates: one after draft generation, one before publishing. The content manager might reject the draft and provide feedback, causing the workflow to stop. Or they approve, and the workflow continues to generate derivative content.

Constraint: Approval steps cannot be nested inside loop or condition steps. They work at the top level of the workflow or inside parallel branches. This is a deliberate design choice — pausing a loop iteration mid-execution creates state management complexity that rarely justifies the use case.

Tip: Approval steps can include an optional input schema. Use this when the approver needs to provide data — revision notes, approved budget amount, selected options — that downstream steps need.

Write-to-KB steps: building institutional knowledge

A write-to-KB step captures a previous step’s output and writes it to a knowledge base document. The workflow continues immediately — it’s a fire-and-forget write that doesn’t block execution.

When to use:

  • Save support ticket resolutions so future runs can reference them via RAG
  • Build a growing library of analyzed contracts, meeting summaries, or research briefs
  • Create searchable records of AI-generated outputs for audit or reuse

Example — Support resolution knowledge base:

Step 1: Triage and classify ticket (recipe)
Step 2: Draft resolution (recipe)
Step 3: Approval (support lead reviews)
Step 4: Write-to-KB (save resolution to "Support Resolutions" KB)
Step 5: Send response to customer (recipe)

After the resolution is approved, it’s written to a knowledge base. Future triage runs can retrieve similar resolutions via RAG, making each resolution smarter than the last.

Tip: Pair write-to-KB steps with auto-context knowledge bases. When a KB is linked to a recipe or department, its documents are automatically included as context in future runs — no manual wiring needed.

Handoff steps: human notification without blocking

A handoff step sends a notification (email and in-app) to users in a target department. Unlike approval steps, handoffs don’t pause the workflow — they alert someone and keep going.

When to use:

  • Escalate an issue to another team without stopping the pipeline
  • Notify a department that work is ready for them to pick up
  • Alert stakeholders about something the workflow found

Example — Incident detection with engineering handoff:

Step 1: Analyze error logs (recipe)
Step 2: Classify severity (recipe)
Step 3: Condition (severity == "critical")
  Then:
    Step 3a: Handoff to Engineering (notification)
    Step 3b: Generate incident report (recipe)
  Else:
    Step 3c: Log to monitoring dashboard (recipe)

The handoff notifies the engineering team immediately, but the workflow doesn’t wait for them to respond — it continues generating the incident report in parallel with the human response.

Tip: Use handoffs for “FYI” notifications and approvals for “please decide.” If downstream steps depend on human judgment, use an approval. If they don’t, a handoff keeps things moving.

Browser action steps: interacting with web applications

A browser action step executes an MCP tool call via the JieGou browser extension. It can click buttons, fill forms, read page content, take screenshots, and interact with platform-specific features in Gmail, Slack, Jira, and other web applications.

When to use:

  • Fill out a form in an internal tool based on workflow data
  • Read data from a web page that doesn’t have an API
  • Take a screenshot of a dashboard for a report
  • Interact with legacy systems that only have a web interface

Example — CRM update after lead qualification:

Step 1: Research prospect (recipe)
Step 2: Qualify lead (recipe)
Step 3: Browser action (update Salesforce record with qualification data)
Step 4: Browser action (add note to HubSpot contact)

The browser extension executes in a dedicated automation window, so it doesn’t interfere with your active browser session. Template arguments map workflow data into the tool call — {{step.step_2.qualification_score}} becomes the value filled into the CRM field.

Tip: Browser action steps work best for the last mile — pushing AI-generated data into systems that lack API access. For systems with API integrations (via MCP servers like Salesforce, HubSpot, Jira), use recipe steps with MCP tools instead, as they’re faster and more reliable.

Combining patterns

The most effective workflows combine multiple step types:

Lead processing with parallel outreach:

Step 1: Research prospect (recipe)
Step 2: Qualify lead (recipe)
Step 3: Condition (qualification_score >= threshold)
  Then:
    Step 3a: Parallel
      Branch A: Draft email (recipe)
      Branch B: Draft LinkedIn message (recipe)
    Step 3b: Sales review (approval)
  Else:
    Step 3c: Archive lead (recipe)

Batch invoice processing:

Step 1: Parse invoice batch → invoices[] (recipe)
Step 2: Loop over invoices
  Step 2.1: Extract data (recipe)
  Step 2.2: Check discrepancies (recipe)
  Step 2.3: Condition (has discrepancies)
    Then: Flag for review (recipe)
    Else: Mark as clean (recipe)
Step 3: Generate summary report (recipe)
Step 4: Finance manager approval (approval)

These patterns compose naturally because each step type has clear semantics: recipes do AI work, conditions branch, loops iterate, parallels fan out, and approvals pause.

Input mapping is the glue

The step types are the verbs. Input mappings are the connective tissue. Every recipe step’s inputs map to one of four sources:

  • static — A hardcoded value
  • workflow_input — A value from the workflow’s top-level inputs
  • step_output — A field from a previous step’s output (e.g., step_1.summary)
  • loop_item — The current item in a loop iteration

Getting input mappings right is the most important part of workflow design. JieGou includes auto-mapping that matches fields by name and type, but reviewing and adjusting the mappings manually ensures data flows correctly.

workflows patterns architecture step-types
Share this article

Enjoyed this post?

Get workflow tips, product updates, and automation guides in your inbox.

No spam. Unsubscribe anytime.