Abstract
Large Language Models (LLMs) have demonstrated effectiveness in code generation tasks. To enable LLMs to address more complex coding challenges, existing research has focused on crafting multi-agent systems with agentic workflows, where complex coding tasks are decomposed into sub-tasks, assigned to specialized agents. Despite their effectiveness, current approaches heavily rely on hand-crafted agentic workflows, with both agent topologies and prompts manually designed, which limits their ability to automatically adapt to different types of coding problems. To address these limitations and enable automated workflow design, we propose Self-Evolving Workflow (SEW), a novel self-evolving framework that automatically generates and optimises multi-agent workflows. Extensive experiments on three coding benchmark datasets, including the challenging LiveCodeBench, demonstrate that our SEW can automatically design agentic workflows and optimise them through self-evolution, bringing up to 33% improvement on LiveCodeBench compared to using the backbone LLM only. Furthermore, by investigating different representation schemes of workflow, we provide insights into the optimal way to encode workflow information with text.
Introduction
While Large Language Models (LLMs) are increasingly capable at coding, complex software tasks often require multi-agent systems (MAS) where different "agents" handle specific sub-tasks such as parsing, writing, and reviewing. Currently, the design of these workflows is a significant bottleneck because they are almost always hand-crafted. Humans decide the topology—determining which agents interact and in what order—and manually write the specific prompts for every agent.
This manual approach is brittle; a workflow optimized for a simple math problem might fail on a complex system design task. For LLMs to reach their full potential, they must be able to design and optimize their own collaboration strategies autonomously. SEW addresses this by automating the generation and refinement of both workflow structures and individual agent prompts.
Methodology: The SEW Framework
The SEW framework operates through three main modules designed to iteratively improve the performance of multi-agent systems.
1. Workflow Generation
The system begins with a task description and a template. It utilizes an LLM to generate an initial multi-agent workflow, establishing the baseline topology for the task.
2. Workflow Evolution
SEW applies a Direct Evolution (DE) operator to the generated workflow. Using "mutation prompts," the framework instructs the LLM to rearrange or modify the workflow's structure. This might involve adding a reviewer agent, changing the sequence of operations, or merging redundant steps to optimize the logic.
3. Agent Evolution
Once the structural topology is finalized, SEW refines the prompts for each individual agent using two primary strategies:
- Direct Evolution (DE): This involves directly mutating the agent's prompt to enhance its specific instructions.
- Hyper Evolution (HE): A meta-evolutionary approach where the LLM first evolves the mutation prompt itself before applying it to improve the agent's prompt.
Workflow Representation
A critical finding of the research was the importance of how a workflow is represented to the LLM. The authors compared formats like BPMN, YAML, Python, and Pseudo-code, concluding that CoRE (Code Representation and Execution) is the most effective. CoRE balances natural language, pseudo-code, and flow-based programming, providing the necessary structure for the LLM to parse and execute complex workflows successfully.
Experimental Evaluation
The authors evaluated SEW on three major coding benchmarks: HumanEval, MBPP (Mostly Basic Python Problems), and LiveCodeBench (LCB). LCB is a particularly challenging, contamination-free benchmark featuring recent competitive coding problems.
Key Results
SEW demonstrated significant performance gains, outperforming the backbone LLM (GPT-4o mini) by 33.9% on LiveCodeBench (increasing pass@1 from 38.0 to 50.9). Furthermore, SEW consistently surpassed other automated prompt and workflow engineering methods, such as AFlow, ADAS, and PromptBreeder, across all tested datasets. The framework proved to be model-agnostic, showing improvements when using both GPT-4o mini and Gemini-1.5-pro as the underlying models.
Discussion and Insights
The study revealed several key insights:
- Peak Performance vs. Robustness: While second-order Direct Evolution (DE) achieved the highest peak performance, Hyper Evolution (HE) exhibited lower variance, suggesting it is a more reliable strategy across diverse tasks.
- Autonomous Complexity: SEW naturally evolved sophisticated engineering patterns, such as iterative debugging and task decomposition, without human intervention.
- Trade-offs: Multi-agent workflows are more resource-intensive than single-agent prompts. The evolved "Code Rewriting" workflows, while highly effective, consumed significantly more tokens due to their iterative nature.
Conclusion
SEW represents a significant step toward fully autonomous software engineering by enabling LLMs to design their own collaborative workflows. By automating the evolution of both topology and prompts, SEW overcomes the limitations of hand-crafted systems, delivering substantial performance improvements on complex coding tasks. Future work will explore the applicability of SEW to non-coding domains and the implementation of more robust runtime validation for evolved workflows.
Summary updated