# Hub-and-spoke: isolated specialists
coordinator = (
Agent("coord", "gemini-2.5-flash")
.instruct("Route to the right team.")
.sub_agent(
Agent("billing").instruct("...").isolate()
)
.sub_agent(
Agent("support").instruct("...").isolate()
)
.sub_agent(
Agent("sales").instruct("...").isolate()
)
.build()
)
# Sequential: .stay() chain, last .isolate()
chain = (
Agent("parent", "gemini-2.5-flash")
.instruct("Manage the pipeline.")
.sub_agent(
Agent("draft").instruct("...").stay()
)
.sub_agent(
Agent("review").instruct("...").stay()
)
.sub_agent(
Agent("publish").instruct("...").isolate()
)
.build()
)
# Nested: sub-coordinators with leaves
root = (
Agent("root", "gemini-2.5-flash")
.instruct("Coordinate research and writing.")
.sub_agent(
Agent("research").isolate()
.sub_agent(Agent("web").isolate())
.sub_agent(Agent("papers").isolate())
)
.sub_agent(
Agent("writing").isolate()
.sub_agent(Agent("draft").isolate())
.sub_agent(Agent("edit").isolate())
)
.build()
)