PBT-Bench:基于属性测试的AI智能体基准
PBT-Bench: Benchmarking AI Agents on Property-Based Testing
AI总结:
提出PBT-Bench基准,包含100个基于属性测试的问题,用于评估AI智能体从文档中推导语义不变量并生成输入策略的能力。
摘要:
现有的代码基准测试衡量的是智能体能否生成任何能复现已知bug的测试,或者能否生成修复描述问题的补丁。两者都没有分离出基于属性测试的独特技能:从文档中推导语义不变量,然后构建足够精确的输入生成策略,使得随机搜索能够揭示违规。我们引入了PBT-Bench,一个包含40个真实Python库中100个精心策划的基于属性测试问题的基准。每个问题注入一个或多个语义bug(共365个,平均每个问题3.65个),设计使得默认策略的随机输入几乎不会触发它们;智能体必须阅读库的文档,识别相关不变量,并指定一个Hypothesis @given策略,将质量集中在触发区域。bug按三个难度级别(L1-L3)分层,涵盖单约束边界bug到有状态、跨函数协议违规。我们在两种提示机制(开放式基线与显式Hypothesis脚手架)下评估了八个当代LLM,每个配置进行三次独立运行。在PBT引导提示下,模型间的bug召回率从42.1%到83.4%不等;在开放式基线下,从31.4%到76.7%不等。Hypothesis脚手架将中等能力模型提升了超过20个百分点,但对最强模型提升较小,有两个例外显示出退化,表明结构化提示可能干扰某些模型行为而非补充。最难的bug被证明是模型特定的:不同架构在不同问题上失败,留下没有单一模型能填补的持续空白。我们发布基准、测试框架和完整评估语料库,以支持下游关于文档基础的语义推理工作。
英文摘要:
Existing code benchmarks measure whether an agent can produce any test that reproduces a known bug, or whether it can produce a patch that fixes a described issue. Neither isolates the distinct skill of property-based testing: deriving a semantic invariant from documentation, and then constructing an input-generation strategy precise enough to make a random search reveal the violation. We introduce PBT-Bench, a benchmark of 100 curated property-based testing problems across 40 real Python libraries. Each problem injects one or more semantic bugs (365 in total, mean 3.65 per problem) designed so that default-strategy random inputs almost never trigger them; the agent must read the library's documentation, identify the relevant invariant, and specify a Hypothesis @given strategy that concentrates mass in the trigger region. Bugs are stratified across three difficulty levels (L1-L3) spanning single-constraint boundary bugs to stateful, cross-function protocol violations. We evaluate eight contemporary LLMs under two prompting regimes (open-ended baseline vs. explicit Hypothesis scaffolding) for three independent runs per configuration. Bug recall under the PBT-guided prompt ranges from 42.1% to 83.4% across models; under the open-ended baseline, from 31.4% to 76.7%. Hypothesis scaffolding lifts mid-capability models by over 20 percentage points, but yields smaller gains for the strongest models, with two exceptions showing degradation, suggesting the structured prompt can interfere with certain model behaviours rather than complementing them. The hardest bugs prove model-specific: different architectures fail on different problems, leaving persistent gaps that no single model closes. We release the benchmark, harness, and full evaluation corpus to support downstream work on documentation-grounded semantic reasoning.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。