让AI生成代码时考虑运行环境限制,显著提升效率与资源利用率。
Substrate-Aware AI Agents: Execution Context as a First-Class Input
- 在代码生成中加入内存和时间约束,引导AI主动优化程序结构。
- 引入执行合约后,平均运行时间减少35%-64%,峰值内存降低49%-74%。
- 适合开发高性能、低资源消耗AI应用的工程师与研究者参考。
自主AI代理在选择动作时,其环境的内存、执行时间、计算和操作约束决定了计划是否可行。我们称代理规划状态中忽略这些执行上下文为‘底座盲视’。通过高维成对欧氏距离任务的代码生成实验验证该命题:使用Anthropic Claude Opus 5、OpenAI GPT-5.6-Sol和Google Gemini 3.7 Flash三种前沿模型,在仅给任务或附加128 MB RAM与10.0秒墙时限制的情况下生成代码。合约披露使14组对比中有13组峰值进程内存下降,且三组均降低平均运行时间,最快提升3.1倍。代码结构变化包括限定阻塞、保留float32精度、上三角遍历及就地/内存映射缓冲区。在更紧的96 MB约束下,独立采样合约披露组分别实现4/5、5/5、3/5正确且符合预算的结果,而任务仅组为0/5、1/5、0/5;均值最大驻留集(MaxRSS)和墙时分别降低49%-74%和35%-64%。结果证明:最小执行合约可促使智能体在生成阶段主动适应,避免无约束分配,显著改善执行前的资源与时间表现。
原文摘要 · Abstract (English)
Autonomous AI agents increasingly select actions in environments whose memory, execution-time, runtime, compute, and operational constraints determine what counts as a suitable plan. We call the absence of this execution context from an agent's planning state substrate blindness. We test this general proposition through numerical code generation, where selected implementation choices and operational consequences are directly observable. Three frontier model configurations--Anthropic Claude Opus 5, OpenAI GPT-5.6-Sol, and Google Gemini 3.7 Flash--generate code for a high-dimensional pairwise Euclidean-distance task either from the task alone or with a 128 MB RAM and 10.0 s wall-time contract. Contract disclosure reduced measured peak process memory in 13 of 14 executable index-aligned task-only versus contract-disclosed comparisons and reduced mean wall time in all three cohorts, making execution up to 3.1x faster. Across the audited corpus, disclosure produced structural code changes including bounded blocking, float32 retention, upper-triangle traversal, and in-place or memory-mapped buffers. At a tighter 96 MB contract, independently sampled contract-disclosed cohorts achieved correct-and-within-budget outcomes of 4/5 for Claude Opus 5, 5/5 for GPT-5.6-Sol, and 3/5 for Gemini 3.7 Flash, compared with task-only outcomes of 0/5, 1/5, and 0/5; cohort mean MaxRSS and wall time were 49-74% and 35-64% lower than their task-only references. These results establish a controlled proof of concept for substrate-aware agent planning: a minimal execution contract induces proactive structural adaptation in generated programs, shifting computation away from unconstrained allocations and substantially improving observed resource-time profiles before execution.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。