Module patterns

Module patterns 

Source
Expand description

Pre-built patterns — common multi-agent workflows.

High-level functions that compose agents into standard patterns: review loops, cascades, fan-out-merge, supervised workflows, etc.

Each function returns a Composable that can be compiled into an executable TextAgent via Composable::compile().

§Examples

use gemini_adk_fluent_rs::prelude::*;

// Review loop: author writes, reviewer checks, loop until approved
let draft = review_loop(
    AgentBuilder::new("author").instruction("Write an essay"),
    AgentBuilder::new("reviewer").instruction("Review and set approved=true when good"),
    3,
);

// Cascade: try agents in order, first success wins
let robust = cascade(vec![
    AgentBuilder::new("primary"),
    AgentBuilder::new("fallback"),
]);

// Fan-out-merge: parallel agents, then merge
let research = fan_out_merge(
    vec![AgentBuilder::new("web"), AgentBuilder::new("db")],
    AgentBuilder::new("synthesizer"),
);

Structs§

MapOver
A map-over workflow node — applies one agent to many items. Build with map_over; compiles to MapOverTextAgent.

Functions§

cascade
Cascade: try agents in sequence, first success wins.
chain
Chain: simple sequential pipeline of agents.
conditional
Conditional: route to one of two agents based on a state predicate.
fan_out_merge
Fan-out-merge: run agents in parallel, then merge results with a merger agent.
map_over
Map-over: apply one agent to every item of a state list.
map_reduce
Map-reduce: map mapper over the list at list_key, then run reducer over the collected results (state["_results"]). A pipeline of a map_over node and the reducer.
review_loop
Review loop: author writes, reviewer checks, loop until approved.
review_loop_keyed
Review loop with a custom quality key and target value.
supervised
Supervised: worker with supervisor oversight loop.
supervised_keyed
Supervised with a custom approval key.