Use the Hierarchical Workflow for complex task decomposition
masterThe HierarchicalWorkflow uses a tree-like structure where tasks flow from top to bottom through multiple levels of specialized agents. This is ideal for sequential processing pipelines, clear reporting structures, and decomposing complex tasks into smaller, specialized roles.
workflow := swarmgo.NewWorkflow(apiKey, llm.OpenAI, swarmgo.HierarchicalWorkflow)
// Add agents to teams
workflow.AddAgentToTeam(managerAgent, swarmgo.SupervisorTeam)
workflow.AddAgentToTeam(researchAgent, swarmgo.ResearchTeam)
workflow.AddAgentToTeam(analysisAgent, swarmgo.AnalysisTeam)
// Connect agents in hierarchy
workflow.ConnectAgents(managerAgent.Name, researchAgent.Name)
workflow.ConnectAgents(researchAgent.Name, analysisAgent.Name)