chart-networkMulti-Agent System Patterns

Explore runnable templates for orchestrating multiple agents with GL AIP.

circle-check

Use these examples to compare architectures (sequential, parallel, router, hierarchical, aggregator, loop) and understand when to apply each one.

Prerequisites

  • Python 3.11 or 3.12

  • uvarrow-up-right package manager installed

  • This repository cloned locally:

    git clone git@github.com:GDP-ADMIN/glaip-sdk.git
  • Environment variables defined in .env:

    OPENAI_API_KEY=your-openai-key-here

Getting Started

Ready-to-run implementations of these patterns are available in the GL SDK Cookbookarrow-up-right.

git clone git@github.com:GDP-ADMIN/gl-sdk-cookbook.git
cd glaip/examples/multi-agent-system-patterns
uv sync
cp .env.example .env  # then edit with your credentials

Run any pattern example with uv, for example the sequential workflow:

Orchestration Approaches

These patterns demonstrate two orchestration approaches, each suited for different workflow types:

gllm-pipeline (Linear Workflows)

Patterns with linear, non-cyclic workflows use gllm-pipelinearrow-up-right for orchestration. gllm-pipeline provides a declarative API with features like:

  • Parallel execution - Run multiple agents simultaneously

  • Sequential workflows - Chain agents where output flows to the next

  • Conditional routing - Direct queries to specialized agents based on logic

  • State management - Track data flow through the pipeline using Pydantic models

Patterns using gllm-pipeline:

  • Sequential, Parallel, Router, Aggregator

To use these patterns, install gllm-pipeline-binary version 0.4.13:

Sub-Agent Delegation (Cyclic Workflows)

Patterns with cyclic workflows or feedback loops use sub-agent delegation instead. This approach allows parent agents to:

  • Make autonomous decisions based on sub-agent responses

  • Loop back to previous steps for refinement

  • Implement quality checks and conditional branching

  • Control iteration limits to prevent infinite loops

Patterns using sub-agent delegation:

  • Hierarchical (coordinator decides based on sub-agent outputs)

  • Loop (optimizer iterates based on executor feedback)

These patterns define sub-agents via the agents parameter when creating the coordinator/optimizer agent.

AgentComponent Wrapper

Patterns using gllm-pipeline (Sequential, Parallel, Router, Aggregator) use the AgentComponent wrapper to integrate glaip_sdk.Agent with gllm-pipeline. This wrapper is now built into the SDK and can be accessed via the .to_component() method.

Note: Sub-agent delegation patterns (Hierarchical, Loop) do not use this wrapper - they use the native agents parameter instead.

Usage

The AgentComponent handles:

  • Converting agents to pipeline-compatible components

  • Compiling structured pipeline state (context, history) into a cohesive prompt

  • Executing agents asynchronously within the pipeline

  • Managing runtime configuration overrides

For more details on advanced usage, see the Agent as Component guide.

Example Structure

Every pattern page shares the same layout so you can skim quickly:

  1. Overview of when the pattern works best

  2. Demo scenario you can run immediately

  3. Diagram showing agent relationships

  4. Implementation steps with code snippets

  5. Run commands and required environment variables

  6. Sample output for validation

  7. Notes and related documentation

Pattern Library

Pattern
When to use
Orchestration
Cookbook Example

Combine specialist insights into one briefing.

gllm-pipeline

Delegate tasks through supervisors for complex workflows.

Sub-agent

Iterative optimization with feedback loops.

Sub-agent

Execute independent tasks simultaneously or compare variants.

gllm-pipeline

Direct each request to the right specialist.

gllm-pipeline

Refine answers step-by-step with predictable stages.

gllm-pipeline

Last updated