智能体
x.com ·
@addyosmani
Addy Osmani:用测试为 Agent 建立自我校验机制
Addy Osmani 建议为 Agent 配备检查自身输出的手段,并列出几类值得投入的测试:编写模拟真实用户流程的端到端测试作为 ground truth;用 property-based testing 规定绝不应发生的情况并生成大量用例尝试突破约束;替换系统时用随机输入对比新旧版本;要求测试快速且确定性,否则 Agent 可能学会重试而非真正修复问题。其核心观点是:示例测试说明应该发生什么,属性测试说明绝不能发生什么。
AI推荐理由 Addy Osmani 提出让 Agent 自我校验输出的具体测试策略:端到端测试模拟真实用户流程作为 ground truth、用 property-based testing 定义不可违反的约束并生成大量用例、替换系统时用随机输入对比新旧版本、要求测试快速且确定性以避免 Agent 学会重试而非修复问题。属于可落地的 Agent 工程实践建议,但为个人经验分享,无实验数据或案例验证,且未提供完整正文。
72
浏览 4,393
点赞 77
评论 10
转发 5
正文
To make your agent produce high-quality output, equip it with a way to check its work. Tests are part of that.
Here are some of the ones I think are worth investing in.
- Write end-to-end tests that simulate real user flows and act as the ground truth
- Use property-based testing to specify what should never happen and generate thousands of test cases that attempt to break those constraints
- If replacing a system, compare the old and new versions using randomly selected inputs
- Require tests to run quickly and deterministically, which reinforces the agent to retry when the loop is slow or unreliable (the agent may learn to retry, not fix the problem)
Example tests say what should happen; properties say what must not.
