Skip to main content
QUICK REVIEW

[论文解读] Can AI Agents Generate Microservices? How Far are We?

Bassam Adnan, Matteo Esposito|arXiv (Cornell University)|Mar 9, 2026
Software System Performance and ReliabilityComputer Science被引用 0
一句话总结

AI 代理可以生成具有可维护代码的功能微服务,在干净状态场景下实现高集成正确性,但完全自主生成仍不完美,需人工监督。

ABSTRACT

LLMs have advanced code generation, but their use for generating microservices with explicit dependencies and API contracts remains understudied. We examine whether AI agents can generate functional microservices and how different forms of contextual information influence their performance. We assess 144 generated microservices across 3 agents, 4 projects, 2 prompting strategies, and 2 scenarios. Incremental generation operates within existing systems and is evaluated with unit tests. Clean state generation starts from requirements alone and is evaluated with integration tests. We analyze functional correctness, code quality, and efficiency. Minimal prompts outperformed detailed ones in incremental generation, with 50-76% unit test pass rates. Clean state generation produced higher integration test pass rates (81-98%), indicating strong API contract adherence. Generated code showed lower complexity than human baselines. Generation times varied widely across agents, averaging 6-16 minutes per service. AI agents can produce microservices with maintainable code, yet inconsistent correctness and reliance on human oversight show that fully autonomous microservice generation is not yet achievable.

研究动机与目标

  • 评估 AI 代理在不同上下文信息水平下,是否能生成具备显式 API 合约的功能微服务。
  • 在增量和干净状态生成设定中,通过自动化测试评估功能正确性。
  • 比较 AI 生成的微服务在代码质量和软件度量方面与人工基线的差异。
  • 评估不同 AI 代理在各场景中的时间、令牌数量与成本等效率。

提出的方法

  • 在 3 个代理、4 个项目、2 种提示策略、2 种场景下评估 144 次微服务生成。
  • 使用增量生成通过单元测试在现有系统内进行验证;使用干净状态生成从需求出发通过集成测试进行验证。
  • 衡量功能正确性(测试通过率)、代码质量(SLOC、圈复杂度、认知复杂度,利用 SonarQube)、以及效率(令牌、时间、成本)。
  • 应用两种提示策略(P1:最小上下文;P2:包含实现摘要)在四种条件下。
  • 进行非参数统计分析(Anderson-Darling、Wilcoxon 有序等级、Dunn-All)且 alpha = 0.01,以比较场景与提示的差异。
Figure 1 : Overview of the Study Design
Figure 1 : Overview of the Study Design

实验结果

研究问题

  • RQ1研究问题 1:在不同上下文场景下,AI 代理是否能够生成具备可接受功能正确性和代码质量的微服务?
  • RQ2研究问题 1.1:在增量生成(具有现有系统上下文)下,AI 代理在微服务方面表现如何?
  • RQ3研究问题 1.2:在干净状态生成(仅从需求出发)下,AI 代理在微服务方面表现如何?
  • RQ4研究问题 2:在生成微服务时,AI 代理在效率(时间、令牌、成本)方面的比较如何?

主要发现

  • 在增量生成中,单元测试通过率平均在 50–76% 之间,取决于代理和提示策略。
  • 在干净状态生成中,集成测试通过率较高,平均在 81–98% 之间,表明 API 合约遵循性强。
  • 生成的代码总体复杂性通常低于人工基线(圈复杂度和认知复杂度较低)。
  • 生成一个微服务的时间平均为 6–16 分钟,取决于代理;Code Qwen 的速度相对较慢,异常情况下可达 1.74 小时。
  • 每个微服务的成本因代理而异,Code Qwen 成本效益最高(约 2.98 美元/服务),Claude Code 成本最高(约 13.28 美元/服务)。
  • P1(最小上下文)在增量生成中优于 P2;在干净状态生成中,部分代理受益于引导;总体而言,仍需人工监督以确保 API 合约合规。
Figure 3 : Code Quality Metrics comparison: Lines of Code (LoC), Cyclomatic Complexity (CycC), and Cognitive Complexity (CogC). Top row shows comparison by agent, bottom row shows comparison by configuration.
Figure 3 : Code Quality Metrics comparison: Lines of Code (LoC), Cyclomatic Complexity (CycC), and Cognitive Complexity (CogC). Top row shows comparison by agent, bottom row shows comparison by configuration.

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。