Source-linked AI summary

SEW: Self-Evolving Agentic Workflows for Automated Code Generation

Siwei Liu, Jinyuan Fang, Han Zhou, Yingxu Wang, Zaiqiao Meng

arXiv:2505.18646v2cs.SEcs.AIcs.CL

TL;DR

Hand-crafted multi-agent workflows require manual design of their topologies and prompts, limiting their adaptation across coding tasks. SEW automatically generates and evolves workflows and agent prompts, and its authors report improved performance over single-agent baselines. The paper also compares workflow representation schemes and identifies CoRE as the most effective among those tested.

  • Problem

    Multi-agent coding workflows rely on manually designed topologies and prompts, limiting their adaptability to different coding tasks.

    Source: §1 · p. 1
  • Method

    SEW automatically generates workflows and jointly evolves workflow structures and agent prompts, while comparing textual representation schemes.

    Source: §1 · pp. 1–2
  • Results

    SEW’s self-evolved workflows consistently outperform single-agent baselines, including those with improved prompts, and CoRE emerges as the most effective tested representation scheme.

    Source: §6 · p. 8
  • Takeaways & Limitations

    SEW offers a direction for reducing reliance on manual workflow design and prompt engineering while improving adaptability and efficiency.

    Source: §6 · p. 9

    SEW’s generalization to reasoning or planning remains unknown, and some logically sound generated workflows fail to produce executable outputs.

    Source: Limitations · p. 9

Abstract

from arXiv · show

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 \textbf{S}elf-\textbf{E}volving \textbf{W}orkflow (\textbf{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 12\% 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.

1 Introduction

Multi-agent workflows divide complex coding tasks among specialized agents, but their topologies and prompts are usually designed by hand. SEW aims to automate workflow generation and optimization, including comparisons of text-based workflow representations.

1 Introduction

  • Complex coding tasks are increasingly challenging for a single LLM instance, motivating multi-agent collaboration.Multi-agent systems decompose programming tasks into subtasks handled by specialized agents with tailored prompts.Source: §1 · p. 1
  • Current multi-agent workflows require manually crafting both topology and prompts, limiting adaptability across coding tasks.The paper notes that workflows optimized for machine-learning tasks can differ significantly from those tailored to software development.Source: §1 · p. 1
  • SEW automatically generates and optimizes multi-agent workflows, including both workflow topology and each agent’s prompt.Its evolutionary scheme improves both, while the paper also compares five textual representation schemes for interpretation and optimization.Source: §1 · pp. 1–2
  • The paper compares BPMN, CoRE, Python, YAML, and pseudo-code as workflow representations for SEW.The comparison considers how well each scheme can be interpreted and optimized by SEW.Source: §1 · p. 2
  • The authors report experiments on MBPP, HumanEval+, and LiveCodeBench showing that SEW improves workflow performance through self-evolution.They describe the framework as constructing workflows from scratch based solely on task descriptions.Source: §1 · p. 2

2 Related Work

Related work covers representations used to specify agent workflows and methods for evolving prompts, agents, and workflow topologies. SEW is positioned as jointly optimizing agent prompts and workflows using multiple representation schemes.

2.1 Workflow Representations in Agents

  • BPMN, CoRE, Python, YAML, and pseudo-code are described as workflow representation schemes used in agentic systems.BPMN depicts execution order, while CoRE combines natural-language programming, pseudo-code, and flow-based programming.Source: §2.1 · p. 2

2.2 Self-Evolving Agents

  • Prior work includes prompt optimizers and methods for evolving agentic workflows, while SEW jointly optimizes agent prompts and workflows across representation schemes.Examples include APE’s candidate search, Promptbreeder’s prompt mutation, MIPRO’s instruction and example refinement, AFlow’s Monte Carlo Tree Search, and EvoFlow’s automated workflow search.Source: §2.2 · p. 2

3 SEW

SEW uses LLM-based workflow generation followed by workflow and agent evolution. Its evolution operators modify workflow structures and agent prompts, with the agent stage using Direct Evolution or Hyper Evolution.

3 SEW

  • The task is to generate executable code from a textual coding problem through collaboration among LLM agents.Each agent processes a textual prompt and produces a textual output; a workflow is a sequence of agents.Source: §3 · p. 2
  • SEW’s three modules are workflow generation, workflow evolution, and agent evolution.It first generates an initial workflow from the task description, reconstructs it through workflow evolution, then equips each agent with a more sophisticated prompt.Source: §3 · p. 3, Figure 2 · p. 3
  • An LLM generates default workflows from the task description and a template expressed in one of five representation schemes.The schemes are BPMN, CoRE, Python, YAML, and pseudo-code.Source: §3 · p. 3
  • Workflow evolution applies a Direct Evolution operator to a textual workflow using a mutation prompt to produce an evolved workflow.SEW evaluates representation schemes using Logical Successful Rate for workflow validity and Generation Successful Rate for executable Python output.Source: §3 · pp. 3–4
  • Direct Evolution modifies an agent’s prompt, whereas Hyper Evolution first modifies the mutation prompt and then applies it to the agent.The framework combines workflow and agent evolution to generate workflow variants for code generation.Source: §3 · pp. 4–5

4 Workflow Representation

SEW examines textual formats for representing workflows, seeking a representation that captures workflow structure and semantics while LLMs can interpret it for downstream modification. It compares five schemes for evolving agentic workflows and illustrates BPMN and CoRE on the same pipeline.

  • A useful representation must capture workflow structure and semantics while remaining interpretable to LLMs for downstream modification.Source: §4 · p. 5
  • SEW compares BPMN, CoRE, Python, YAML, and pseudo-code to identify suitable workflow representations for LLM understanding and execution during workflow evolution.Source: §4 · pp. 5–6
  • Figure 4 contrasts BPMN and CoRE representations of one software-development pipeline, using task nodes for stages and sequence flows for dependencies; both are intended to perform the same function.Source: Figure 4 · p. 5, §4 · p. 6
  • BPMN emphasizes task order and dependencies, while CoRE combines natural-language programming, pseudo-code, and flow-based programming and supports executable, LLM-interpretable workflows.Source: §4 · p. 5
  • Python offers familiar, flexible programmatic integration; YAML supports readable hierarchical configuration, while pseudo-code bridges natural language and formal code for human and machine readability.Source: §4 · p. 5

5 Experiments

Experiments compare SEW with prompting and workflow-design baselines across three coding datasets, then analyze workflow representations and evolution strategies. SEW outperforms the baselines, while the analyses identify trade-offs among representation quality, performance, and robustness.

5.1 Dataset

  • LCB testing uses 300 code-generation samples after 100 randomly sampled validation examples; MBPP and HumanEval+ follow AFlow's data split.The LCB set is the release_v1 code-generation subset.Source: §5.1 · p. 6, §5.2 · p. 6

5.2 Baselines

  • Baselines include two backbone models, Chain-of-Thought, ADAS, AFlow, and PromptBreeder across Claude Opus 4.6 and GPT-5.3.The evaluation covers HumanEval+, MBPP, and LCB.Source: §5.2 · p. 6

5.3 Experimental Setup

  • The authors select task parsing and code rewriting workflows for analysis because variants built on them often improve performance over other generated workflows.They search workflows represented in BPMN, CoRE, Python, YAML, and pseudo-code.Source: §5.3 · p. 6

5.4 Main Results

  • SEW outperforms both backbone models, Chain-of-Thought, ADAS, and AFlow under the same settings; Claude Opus 4.6 generally outperforms GPT-5.3 across the three datasets.The authors report the Claude-versus-GPT pattern on MBPP and LCB.Source: §5.4 · p. 7

5.5 Analysis

  • 91.5% is BPMN's highest LSR, but CoRE achieves the best GSR and is identified as the most effective workflow representation.The authors describe CoRE as combining natural-language, pseudo-code, and flow programming.Source: §5.5 · p. 7
  • SEW’s workflow evolution produces code-rewriting workflows that consistently outperform the Claude Opus 4.6 backbone across three datasets; agent evolution improves task-parsing performance by 9.5% on LCB.The authors attribute the initial improvement to novel workflow topologies and further gains to high-quality prompts generated for each agent.Source: §5.5 · p. 8
  • HE shows lower variance than DE, while second-order DE reaches around 0.57–0.60 pass@10 for Code Rewriting; the authors frame the choice as robustness versus peak performance.They describe lower-order DE and zero-order HE as more robust, and second-order DE and first-order HE as suited to maximizing performance with some variability.Source: §5.5 · p. 8, Figure 5 · p. 8

6 Conclusion

SEW evolves workflows and agent prompts for code generation, with reported benefits over single-agent baselines across three benchmarks. The authors identify higher-order evolution and CoRE as promising directions.

6 Conclusion

  • Across three coding benchmarks, self-evolved workflows outperform single-agent baselines even when those baselines use improved prompts.The conclusion also reports that higher-order evolution strategies further improve workflow effectiveness.Source: §6 · p. 8
  • Higher-order evolution strategies further improve workflow effectiveness by refining task execution dynamics.The conclusion describes this as an additional improvement to workflow effectiveness.Source: §6 · p. 8
  • CoRE is the most effective of the tested workflow representation schemes, balancing logical correctness and execution success.The conclusion presents this as the result of comparing different representation schemes.Source: §6 · p. 8
  • SEW offers a direction for reducing reliance on manual workflow design and prompt engineering while improving adaptability and efficiency.These are the conclusion's stated implications for agentic workflow optimization.Source: §6 · p. 9

Limitations

The authors identify limits in SEW’s task scope, workflow execution, and dependence on the underlying LLM. Its generalization beyond code generation remains unknown.

Limitations

  • SEW’s generalization to other AI-driven tasks, such as reasoning or planning, remains unknown.The authors frame this as an open boundary on its demonstrated applicability.Source: Limitations · p. 9
  • Some generated workflows that are logically sound fail to produce executable outputs.The authors identify a need for more robust validation mechanisms in response.Source: Limitations · p. 9
  • SEW’s effectiveness depends on the capabilities of the underlying LLM.The authors note that future LLM architecture advancements could significantly affect its performance.Source: Limitations · p. 9

A.1 Workflow Representation Schemes

The appendix illustrates workflow encodings in several textual formats, alongside BPMN and CoRE scripts. The examples show workflow steps, agent inputs, and outputs.

A.1 Workflow Representation Schemes

  • The five workflow representation schemes are BPMN, CoRE, Python, YAML, and pseudo-code.The appendix identifies BPMN and CoRE as scripts and presents Python, YAML, and pseudo-code versions of the same workflow.Source: §A.1 · p. 10
  • The Python and YAML examples encode named agents as ordered steps with specified arguments and outputs.The examples include task parsing, task refinement, code generation, code review, and code refinement agents.Source: §A.1 · p. 10
  • The pseudo-code example expresses the workflow as agent calls that pass outputs such as parsed_task and generated_code to later steps.It ends with code refinement using the refined task and review comments.Source: §A.1 · p. 10

A.2 Prompt Corpus

The appendix documents prompts, dataset descriptions, and example workflows before and after agent evolution. Its examples cover code-oriented workflow stages as well as evolved prompt and code outputs.

A.2 Prompt Corpus

  • The prompt corpus describes LiveCodeBench, HumanEval+, and MBPP as code-generation tasks with different problem and evaluation formats.LiveCodeBench uses unseen test cases, HumanEval+ contains 164 handcrafted problems, and MBPP has approximately 1,000 crowd-sourced problems.Source: §A.2 · p. 11
  • A template workflow guides LLMs in generating default workflows, while agent prompts specify roles, objectives, inputs, and outputs.The default workflow prompt also asks for workflow steps, sequence, and agent responsibilities based on a workflow template and dataset description.Source: §A.2 · p. 11
  • The evolutionary prompt set includes mutation, hyper-mutation, and thinking-style prompts, which the paper locates in PromptBreeder’s appendix..Source: §A.2 · p. 12

A.2.1 Workflows without agent evolution module

  • Before agent evolution, the Task Parsing Workflow passes a task summary to code generation, while the Code Rewriting Workflow adds review and rewriting stages.The appendix notes that reviewer and rewriting agents may form a loop.Source: §A.2.1 · p. 12

A.2.2 Workflows improved by agent evolution module

  • An evolved code example adds function extraction, error handling, and invalid-input feedback to a square-number program.The example also discusses clearer code and handling edge cases.Source: §A.2.2 · p. 13
  • The evolved mutator example asks for unconventional combinations and applications, while reviewer suggestions call for flexible inputs, randomness, and documentation.The prompt also invites visual or narrative outputs.Source: §A.2.2 · pp. 13–15
  • A separate example generates random words and uses them to create a scatter plot as visual art.The accompanying code accepts the requested number of words and displays the resulting plot.Source: §A.2.2 · pp. 15–16

A.3 Examples of Failed Python Workflows

The examples show two distinct failures in generated Python workflows: one ends without a code-producing final agent, while another contains an incompatible agent handoff.

A.3 Examples of Failed Python Workflows

  • One failed workflow ends with a reviewer rather than a coding agent, so its final output cannot solve the coding task.Source: §A.3 · p. 16
  • The illustrated pipeline parses and refines the task, generates code, then passes the task and generated code to a reviewer.The example sequence names task parsing, task refinement, code generation, and code review agents.Source: §A.3 · p. 16
  • Another workflow routes generated code to a fortune-telling agent expecting refined_code, leaving that agent unable to fetch its input.Source: §A.3 · p. 16

A.4 Token costs

The section compares token use across the backbone-only model and two SEW-generated workflows, noting higher costs on LiveCodeBench and in multi-agent workflows.

A.4 Token costs

  • The comparison covers backbone-only GPT-4o mini and SEW-generated Task Parsing and Code Rewriting workflows.Source: §A.4 · p. 16
  • LiveCodeBench has higher per-instance token costs than HumanEval+ and MBPP.Source: §A.4 · p. 16
  • Both workflows cost more tokens than GPT-4o mini, with Code Rewriting especially costly because code generation may take multiple reviewer rounds.Source: §A.4 · p. 16
Loading 2505.18646v2…