AgentFactory: A Self-Evolving Framework Through Executable Subagent Accumulation and Reuse
Organizations: Peking University · Beijing Academy of Artificial Intelligence · Hong Kong Polytechnic University
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.
Figures & tables
| Avg. Tokens / Task | |||
|---|---|---|---|
| Method | Task Setting | Opus 4.6 | Sonnet 4.6 |
| ReAct | Batch 1 | 8298 | 6893 |
| Batch 2 | 7022 | 7029 | |
| Self-Evolving Agents | Batch 1 (from scratch) | 8608 | 8163 |
| Batch 2 (w/ saved) | 6210 | 8223 | |
| AgentFactory | Batch 1 (from scratch) | 4324 | 9199 |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| # | Task Description |
|---|---|
| 1 | Among various online discussions about the housing price bubble, how has public sentiment changed over time? Generate an analysis report and a trend chart, and include discussion and summary in the report. |
| 2 | Search for and open the Stanford CS231n course homepage, find the syllabus or lecture list, and output the topics and corresponding links for the first 5 lectures. Save the final results to a markdown file. |
| 3 | Book a Tencent Meeting for tomorrow at 4 PM with the topic “Work Meeting”. Find the meeting booking entry on the Tencent Meeting web version, then complete the booking through browser automation. Output the meeting invitation details, meeting ID, and meeting link. |
| 4 | Search for China’s historical population data, then use matplotlib to plot the population change curve. |
| 5 | Search for Bitcoin’s price data over the past 5 years, use matplotlib to plot the price trend, and calculate the annualized volatility. |
| 6 | Search for and download trending keyword frequency data from a social media platform, and display the top 20 using a bar chart. |
| # | Task Description |
|---|---|
| 1 | Among various online discussions about electric vehicle adoption, how has public sentiment changed over time? Generate an analysis report and a trend chart, and include discussion and summary in the report. |
| 2 | Search for and open the MIT 6.S191 (Introduction to Deep Learning) course homepage, find the syllabus or lecture list, and output the topics and corresponding links for the first 5 lectures. Save the final results to a markdown file. |
| 3 | Book a Tencent Meeting for tomorrow at 7 PM with the topic “Work Meeting”. Find the meeting booking entry on the Tencent Meeting web version, then complete the booking through browser automation. Output the meeting invitation details, meeting ID, and meeting link. |
| 4 | Search for Japan’s historical population data, then use matplotlib to plot the population change curve. |
| 5 | Search for Ethereum’s price data over the past 5 years, use matplotlib to plot the price trend, and calculate the annualized volatility. |
| 6 | Search for and download trending topic data from a Chinese social media platform, and display the top 20 using a bar chart. |
Self-Evolving Agents
Self-evolving agents improve their skills, memory, tools, policies, or environments by learning from interaction and evaluation feedback.
See all 421 papers