跳转至

文章背景与核心概要

随着大语言模型(LLM)在软件工程领域的广泛应用,如何通过规范和引导提升AI编码代理(Coding Agents)的代码生成质量成为了一个核心研究方向。本文探讨了架构规范的格式如何影响LLM编码代理生成代码的质量,以及这种影响是否随模型能力的不同而变化。通过对来自三大厂商(Anthropic Claude、OpenAI GPT和Google Gemini)的6个模型进行共计90次多轮代理试验的控制实验,研究评估了五种信息等效的规范格式。

研究的核心发现表明,对于顶尖前沿模型而言,规范格式的选择对最终质量影响较小;然而,对于中低端模型,架构规范则扮演了“能力均衡器”的关键角色——代码紧耦合的格式(如OpenAPI和TypeScript契约)能够显著弥补模型自身能力上的差距,甚至将最弱模型的API路由覆盖率从33%提升至100%。这项研究为成本优化部署和中低端模型的实际应用提供了极具价值的架构设计参考。


架构作为代码Agent的能力均衡器 (Architecture as Capability Equalizer for Coding Agents)

arXiv: 2608.21747 [cs.SE]
Authors: Arquimedes Canedo
Submitted: August 22, 2026
Subjects: Software Engineering (cs.SE); Artificial Intelligence (cs.AI); Computation and Language (cs.CL)


执行摘要 (Executive Summary)

本文研究了架构规范的格式如何影响大语言模型(LLM)编码代理(coding agents)生成的代码质量,以及这种影响是否随模型能力的不同而变化。通过包含来自三个厂商(Anthropic Claude、OpenAI GPT和Google Gemini)的六个模型的共计 90 次多轮代理试验(multi-turn agent trials)的控制实验,本研究评估了五种信息等效的规范格式: 1. 非正式散文(Informal prose) 2. 带约束和ADR的Mermaid图表(Mermaid diagrams with constraints and ADRs) 3. OpenAPI 4. C4/Structurizr DSL 5. 带有ArchUnit风格规则的TypeScript接口契约(TypeScript interface contracts with ArchUnit-style rules)

This paper investigates how the format of architecture specifications impacts the quality of code generated by Large Language Model (LLM) coding agents, and whether this effect varies depending on model capability. Through a controlled experiment comprising 90 multi-turn agent trials across six models from three vendor families (Anthropic Claude, OpenAI GPT, and Google Gemini), the study evaluates five informationally equivalent specification formats: 1. Informal prose 2. Mermaid diagrams with constraints and ADRs 3. OpenAPI 4. C4/Structurizr DSL 5. TypeScript interface contracts with ArchUnit-style rules

核心发现 (Key Findings)

  • 模型能力调节效应: 对于前沿模型(例如 Claude Sonnet 4.6、GPT-5),规范格式几乎没有影响,其质量极差范围收窄在 0.170.92 之间。
  • “能力均衡器”效应: 对于较弱或中端模型,规范格式的选择会极大地改变性能,产生 0.832.42 点的质量差距。与代码紧密相关的格式(如 OpenAPI 和 TypeScript 契约)成功弥合了能力差距。
  • Token 效率与调试循环: 中端模型通常比前沿模型消耗显著更多的 Token,同时产生较差的输出,因为它们陷入了更强模型能够轻松避免的编译调试循环中。
  • 自我验证崩溃: 跨模型能力谱系,自我验证率从 100%(Claude Sonnet)急剧下降到 0%(Gemini Flash)。
  • 具体改进: 事实证明,TypeScript 契约使最弱模型的 API 路由覆盖率增加了两倍,从 33% 提高到 100%
  • Model Capability Moderation: For frontier models (e.g., Claude Sonnet 4.6, GPT-5), the specification format barely matters, with quality spreads tightly ranging from 0.17 to 0.92.
  • The "Capability Equalizer" Effect: For weaker or mid-tier models, the choice of specification format drastically alters performance, producing quality spreads of 0.83 to 2.42 points. Code-proximate formats (such as OpenAPI and TypeScript contracts) successfully bridge the capability gap.
  • Token Efficiency & Debug Loops: Mid-tier models often consume significantly more tokens than frontier models while producing inferior output due to getting trapped in compilation debugging loops that stronger models effortlessly avoid.
  • Self-Validation Collapses: Self-validation rates drop steeply from 100% (Claude Sonnet) down to 0% (Gemini Flash) across the model capability spectrum.
  • Concrete Improvements: TypeScript contracts were shown to triple API route coverage for the weakest model, raising it from 33% up to 100%.

归根结底,结构化的架构规范充当了强大的能力均衡器,为成本优化部署和较弱的模型提供了最高的投资回报率。

Ultimately, structured architecture specifications act as a powerful capability equalizer, offering the highest return on investment for cost-optimized deployments and weaker models.