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.

Do we have to move our files?

No. Your documents stay where they are, in Drive, Dropbox, Litify, or Filevine. We read from them and keep watching for new ones. Nothing gets migrated into a platform you would have to leave later.

What exactly do we own?

The data layer. The database, the schema, the pipelines, and the full extraction history live in your firm's cloud and belong to you outright. The workflows and agents that run on top are licensed while we work together. You own the record, and you license the tools that read it.

What happens if we stop working with you?

You keep the data layer and everything in it, running in your own environment. The workflows and agents switch off, and you are free to point other tools at the record you own. Nothing has to be exported, because nothing was ever held anywhere else.

Who can see our client data?

Only the people who can see it today. Everything runs in your firm's own cloud, privilege is gated at the database rather than inside an app, every access is logged, and your data is never used to train anyone's model.

Do we have to leave Litify?

No, and we would not recommend it. Litify stays your system of record. We mirror cases, parties, and assignments from it, and we can write extracted facts back into your fields, so the system your team already knows gets better rather than replaced.

How is it priced?

A build fee for the asset you own, then a flat monthly retainer covering operations and the workflows and agents in use. No per-seat fees and no per-question metering. Your bill does not grow because your team used it more.

What happens when the AI gets something wrong?

You catch it, which is the design. Every answer carries the documents it came from, nothing is filed or sent without a person approving it, and every correction improves the system. The attorney remains responsible for the work product, so the platform is built to make supervising it easy.

Does this replace people on our team?

No. It removes the gathering, retyping, and remembering, which was never the job. Judgment, advocacy, and the client relationship stay exactly where they are.

FAQ

Frequently asked questions

Everything you need to know to get started.

Do we have to move our files?

No. Your documents stay where they are, in Drive, Dropbox, Litify, or Filevine. We read from them and keep watching for new ones. Nothing gets migrated into a platform you would have to leave later.

What exactly do we own?

The data layer. The database, the schema, the pipelines, and the full extraction history live in your firm's cloud and belong to you outright. The workflows and agents that run on top are licensed while we work together. You own the record, and you license the tools that read it.

What happens if we stop working with you?

You keep the data layer and everything in it, running in your own environment. The workflows and agents switch off, and you are free to point other tools at the record you own. Nothing has to be exported, because nothing was ever held anywhere else.

Who can see our client data?

Only the people who can see it today. Everything runs in your firm's own cloud, privilege is gated at the database rather than inside an app, every access is logged, and your data is never used to train anyone's model.

Do we have to leave Litify?

No, and we would not recommend it. Litify stays your system of record. We mirror cases, parties, and assignments from it, and we can write extracted facts back into your fields, so the system your team already knows gets better rather than replaced.

How is it priced?

A build fee for the asset you own, then a flat monthly retainer covering operations and the workflows and agents in use. No per-seat fees and no per-question metering. Your bill does not grow because your team used it more.

What happens when the AI gets something wrong?

You catch it, which is the design. Every answer carries the documents it came from, nothing is filed or sent without a person approving it, and every correction improves the system. The attorney remains responsible for the work product, so the platform is built to make supervising it easy.

Does this replace people on our team?

No. It removes the gathering, retyping, and remembering, which was never the job. Judgment, advocacy, and the client relationship stay exactly where they are.

FAQ

Frequently asked questions

Everything you need to know to get started.

Do we have to move our files?

No. Your documents stay where they are, in Drive, Dropbox, Litify, or Filevine. We read from them and keep watching for new ones. Nothing gets migrated into a platform you would have to leave later.

What exactly do we own?

The data layer. The database, the schema, the pipelines, and the full extraction history live in your firm's cloud and belong to you outright. The workflows and agents that run on top are licensed while we work together. You own the record, and you license the tools that read it.

What happens if we stop working with you?

You keep the data layer and everything in it, running in your own environment. The workflows and agents switch off, and you are free to point other tools at the record you own. Nothing has to be exported, because nothing was ever held anywhere else.

Who can see our client data?

Only the people who can see it today. Everything runs in your firm's own cloud, privilege is gated at the database rather than inside an app, every access is logged, and your data is never used to train anyone's model.

Do we have to leave Litify?

No, and we would not recommend it. Litify stays your system of record. We mirror cases, parties, and assignments from it, and we can write extracted facts back into your fields, so the system your team already knows gets better rather than replaced.

How is it priced?

A build fee for the asset you own, then a flat monthly retainer covering operations and the workflows and agents in use. No per-seat fees and no per-question metering. Your bill does not grow because your team used it more.

What happens when the AI gets something wrong?

You catch it, which is the design. Every answer carries the documents it came from, nothing is filed or sent without a person approving it, and every correction improves the system. The attorney remains responsible for the work product, so the platform is built to make supervising it easy.

Does this replace people on our team?

No. It removes the gathering, retyping, and remembering, which was never the job. Judgment, advocacy, and the client relationship stay exactly where they are.

Own your firm's Intelligence.

Start with a four-week assessment. We map your documents and show you what your files can actually tell you. You keep the findings either way.

Own your firm's Intelligence.

Start with a four-week assessment. We map your documents and show you what your files can actually tell you. You keep the findings either way.

Own your firm's Intelligence.

Start with a four-week assessment. We map your documents and show you what your files can actually tell you. You keep the findings either way.