Tutorial

Advanced agent patterns: working with loops and more

Take your agents to the next level with advanced workflow patterns — from conditional logic to approval workflows to multi-agent orchestration.

Published on

Written by

Professional headshot of a man wearing glasses against a natural background.

Ryan Tanaka

Scenic alpine lake with snow-covered mountains, forested slopes, and clear reflections on still water.

You've built your first agent. It handles simple tasks reliably. Now you want to tackle more complex workflows. This guide covers three advanced patterns that unlock the full power of AI agents.

Pattern 1: Conditional Branching

Real-world workflows rarely follow a straight line. Depending on the input, your agent might need to take completely different paths. That's where conditional branching comes in.

In the Visual Builder, add a "Condition" node after any step. Define your branching logic using natural language or structured rules. For example: "If refund amount > $100, require manager approval. Otherwise, process automatically."

You can chain multiple conditions to create complex decision trees. Each branch can have its own sequence of actions, tools, and even different LLM configurations. The agent evaluates conditions in real-time based on the conversation context and available data.

Pro tip: Use conditions sparingly. Every branch adds complexity and potential failure points. If you find yourself with more than 5-6 branches, consider breaking the workflow into multiple specialized agents instead.

Pattern 2: Loops and Iteration

Some tasks require repetition. Processing a list of items, retrying failed operations, or gathering information until a condition is met. Our loop pattern handles all of these.

The "Loop" node lets you define: what to iterate over (a list, a condition, or a count), what actions to perform each iteration, when to break out of the loop, and how to handle errors within iterations.

For example, imagine an agent that enriches lead data. You give it a list of 100 leads. The loop processes each one: looking up the company, finding contact info, scoring fit, and updating your CRM. If any lookup fails, it logs the error and continues to the next lead.

Without loops, you'd need 100 separate executions. With loops, it's a single workflow that handles everything automatically, including progress tracking and error recovery.

Pattern 3: Human-in-the-Loop

Not everything should be fully automated. Sometimes you want human oversight for high-stakes decisions. The Human-in-the-Loop pattern lets you pause workflows for human approval without losing context.

Add an "Approval" node wherever you need human input. Configure who should approve (specific users, roles, or dynamic assignment), what information to show them, how long to wait before timing out, and what to do if approval is denied.

When the workflow hits this node, it pauses and sends a notification to the approver. They see the full context: what the agent has done so far, what it wants to do next, and why. They can approve, reject, or modify the proposed action.

Once approved, the workflow continues exactly where it left off. All context is preserved. The agent might even learn from the approval patterns — if managers always approve requests under a certain threshold, you might adjust the automation rules.

We see customers using this pattern for: refunds over a certain amount, contract modifications, access provisioning, and any action that affects production systems. It's the perfect balance between automation efficiency and human judgment.

Putting It All Together

The most powerful agents combine all three patterns. Imagine a procurement agent that: loops through purchase requests, branches based on amount and vendor, requires human approval above $10k, and automatically processes everything else.

That's a workflow that used to require multiple people, email chains, and days of delay. Now it runs in minutes with full auditability and consistent enforcement of your policies.

Start simple, add complexity gradually, and always test thoroughly in sandbox before deploying. The patterns are powerful — use them wisely.

FAQ

your questions, answered

Everything you need to know to get started.

Does this work with Goodnotes, Notability, or Bear?

Yes. StudyMapp does not replace the app you write in. It's an entirely different tool to help you remember and study your notes. Export or share a page from any notes app and it becomes a note here. You keep writing wherever you already write.

Do I have to make flashcards?

Not at all. A note is a page you already wrote. You drag a few tiles over the parts you want to be tested on and that is the whole setup.

Why rewrite on paper instead of tapping an answer?

Recalling something and producing it yourself is a stronger memory operation than recognising it.

Does it sync between my iPhone and iPad?

Yes, over iCloud, using your own iCloud account. Notes, folders, tiles and review history all carry across.

Are my notes or handwriting sent anywhere?

Never. Notes are stored on your device and in your own private iCloud storage. There is no StudyMapp server holding your pages, and nothing is used to train anything.

FAQ

your questions, answered

Everything you need to know to get started.

Does this work with Goodnotes, Notability, or Bear?

Yes. StudyMapp does not replace the app you write in. It's an entirely different tool to help you remember and study your notes. Export or share a page from any notes app and it becomes a note here. You keep writing wherever you already write.

Do I have to make flashcards?

Not at all. A note is a page you already wrote. You drag a few tiles over the parts you want to be tested on and that is the whole setup.

Why rewrite on paper instead of tapping an answer?

Recalling something and producing it yourself is a stronger memory operation than recognising it.

Does it sync between my iPhone and iPad?

Yes, over iCloud, using your own iCloud account. Notes, folders, tiles and review history all carry across.

Are my notes or handwriting sent anywhere?

Never. Notes are stored on your device and in your own private iCloud storage. There is no StudyMapp server holding your pages, and nothing is used to train anything.

FAQ

your questions, answered

Everything you need to know to get started.

Does this work with Goodnotes, Notability, or Bear?

Yes. StudyMapp does not replace the app you write in. It's an entirely different tool to help you remember and study your notes. Export or share a page from any notes app and it becomes a note here. You keep writing wherever you already write.

Do I have to make flashcards?

Not at all. A note is a page you already wrote. You drag a few tiles over the parts you want to be tested on and that is the whole setup.

Why rewrite on paper instead of tapping an answer?

Recalling something and producing it yourself is a stronger memory operation than recognising it.

Does it sync between my iPhone and iPad?

Yes, over iCloud, using your own iCloud account. Notes, folders, tiles and review history all carry across.

Are my notes or handwriting sent anywhere?

Never. Notes are stored on your device and in your own private iCloud storage. There is no StudyMapp server holding your pages, and nothing is used to train anything.

ready to change how you study?

20 notes for free. No credit card required.

ready to change how you study?

20 notes for free. No credit card required.

ready to change how you study?

20 notes for free. No credit card required.