AMAS: Adaptively Determining Communication Topology for LLM-based Multi-Agent System