Table of Contents
Fetching ...

AgentFactory: A Self-Evolving Framework Through Executable Subagent Accumulation and Reuse

Zhang Zhang, Shuqi Lu, Hongjin Qian, Di He, Zheng Liu

Abstract

Building LLM-based agents has become increasingly important. Recent works on LLM-based agent self-evolution primarily record successful experiences as textual prompts or reflections, which cannot reliably guarantee efficient task re-execution in complex scenarios. We propose AgentFactory, a new self-evolution paradigm that preserves successful task solutions as executable subagent code rather than textual experience. Crucially, these subagents are continuously refined based on execution feedback, becoming increasingly robust and efficient as more tasks are encountered. Saved subagents are pure Python code with standardized documentation, enabling portability across any Python-capable system. We demonstrate that AgentFactory enables continuous capability accumulation: its library of executable subagents grows and improves over time, progressively reducing the effort required for similar tasks without manual intervention. Our implementation is open-sourced at https://github.com/zzatpku/AgentFactory, and our demonstration video is available at https://youtu.be/iKSsuAXJHW0.

AgentFactory: A Self-Evolving Framework Through Executable Subagent Accumulation and Reuse

Abstract

Building LLM-based agents has become increasingly important. Recent works on LLM-based agent self-evolution primarily record successful experiences as textual prompts or reflections, which cannot reliably guarantee efficient task re-execution in complex scenarios. We propose AgentFactory, a new self-evolution paradigm that preserves successful task solutions as executable subagent code rather than textual experience. Crucially, these subagents are continuously refined based on execution feedback, becoming increasingly robust and efficient as more tasks are encountered. Saved subagents are pure Python code with standardized documentation, enabling portability across any Python-capable system. We demonstrate that AgentFactory enables continuous capability accumulation: its library of executable subagents grows and improves over time, progressively reducing the effort required for similar tasks without manual intervention. Our implementation is open-sourced at https://github.com/zzatpku/AgentFactory, and our demonstration video is available at https://youtu.be/iKSsuAXJHW0.
Paper Structure (42 sections, 3 figures, 3 tables)

This paper contains 42 sections, 3 figures, 3 tables.

Figures (3)

  • Figure 1: Overview of the AgentFactory pipeline. The figure illustrates two boundary cases. Q1 represents a task where no relevant subagents exist: the Meta-Agent creates new subagents from scratch and saves them to the subagent pool. Q2 represents a task where a matching subagent already exists: the Meta-Agent reuses it and modifies it through the self-evolving process to handle the new requirements. In practice, most tasks fall between these two extremes---the Meta-Agent reuses some existing subagents for part of the problem while constructing new ones for the remainder. Over multiple rounds, each task may create or modify several subagents, gradually building a rich and capable subagent pool that can eventually be exported for use by other systems.
  • Figure 2: Evolution of path resolution mechanism across three runs.
  • Figure 3: Demonstration of subagent saving and direct reuse across three trajectories.