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

Frequently asked questions

Everything you need to know to get started.

What's the difference between an agent and a chatbot?

An AI agent goes beyond simple Q&A. It can understand goals, make decisions, use tools, and take actions autonomously — like resolving tickets or running workflows.

Do I need coding experience to get started?

Not at all. Our visual canvas lets you build agents with drag-and-drop. For more control, our SDK and API offer full flexibility.

Which LLM providers do you support?

All major providers — OpenAI, Anthropic, Google Gemini, Mistral, Llama, Cohere, and more. Bring your own keys or use ours.

Is there a free tier available?

Yes. We offer a generous free tier to get started — no credit card required. Paid plans scale with your usage.

Can I self-host or deploy on-prem?

Yes. We offer cloud, hybrid, and on-prem deployment options to fit your security and compliance needs.

How long does it take to deploy an agent?

Minutes. Build your workflow, hit deploy, and you're live. No DevOps, no infrastructure setup — we handle all of it.

Can I connect my existing tools and APIs?

Yes. We integrate with 150+ tools out of the box — Slack, Notion, Salesforce, databases, and more. Custom APIs supported too.

What kind of support do you offer?

Free tier includes docs and community support. Paid plans get priority support, dedicated Slack channels, and onboarding help.

FAQ

Frequently asked questions

Everything you need to know to get started.

What's the difference between an agent and a chatbot?

An AI agent goes beyond simple Q&A. It can understand goals, make decisions, use tools, and take actions autonomously — like resolving tickets or running workflows.

Do I need coding experience to get started?

Not at all. Our visual canvas lets you build agents with drag-and-drop. For more control, our SDK and API offer full flexibility.

Which LLM providers do you support?

All major providers — OpenAI, Anthropic, Google Gemini, Mistral, Llama, Cohere, and more. Bring your own keys or use ours.

Is there a free tier available?

Yes. We offer a generous free tier to get started — no credit card required. Paid plans scale with your usage.

Can I self-host or deploy on-prem?

Yes. We offer cloud, hybrid, and on-prem deployment options to fit your security and compliance needs.

How long does it take to deploy an agent?

Minutes. Build your workflow, hit deploy, and you're live. No DevOps, no infrastructure setup — we handle all of it.

Can I connect my existing tools and APIs?

Yes. We integrate with 150+ tools out of the box — Slack, Notion, Salesforce, databases, and more. Custom APIs supported too.

What kind of support do you offer?

Free tier includes docs and community support. Paid plans get priority support, dedicated Slack channels, and onboarding help.

FAQ

Frequently asked questions

Everything you need to know to get started.

What's the difference between an agent and a chatbot?

An AI agent goes beyond simple Q&A. It can understand goals, make decisions, use tools, and take actions autonomously — like resolving tickets or running workflows.

Do I need coding experience to get started?

Not at all. Our visual canvas lets you build agents with drag-and-drop. For more control, our SDK and API offer full flexibility.

Which LLM providers do you support?

All major providers — OpenAI, Anthropic, Google Gemini, Mistral, Llama, Cohere, and more. Bring your own keys or use ours.

Is there a free tier available?

Yes. We offer a generous free tier to get started — no credit card required. Paid plans scale with your usage.

Can I self-host or deploy on-prem?

Yes. We offer cloud, hybrid, and on-prem deployment options to fit your security and compliance needs.

How long does it take to deploy an agent?

Minutes. Build your workflow, hit deploy, and you're live. No DevOps, no infrastructure setup — we handle all of it.

Can I connect my existing tools and APIs?

Yes. We integrate with 150+ tools out of the box — Slack, Notion, Salesforce, databases, and more. Custom APIs supported too.

What kind of support do you offer?

Free tier includes docs and community support. Paid plans get priority support, dedicated Slack channels, and onboarding help.

Ready to ship your first agent?

Get started free. No credit card required.

Ready to ship your first agent?

Get started free. No credit card required.

Ready to ship your first agent?

Get started free. No credit card required.

Create a free website with Framer, the website builder loved by startups, designers and agencies.