案例分析一:一个陌生 Python 项目如何被 Coding Agent 自动修复?

场景背景

项目:

workspace/
├── AGENTS.md
├── calculator.py
└── tests/
    └── test_calculator.py

Bug:

def add(a, b):
    return a - b

用户,“修复当前 pytest 失败。”

Step 1:扫描

Agent:

list_files

得到:

AGENTS.md
calculator.py
tests/test_calculator.py

Step 2:读取规则

read_file("AGENTS.md")

得到:

不能修改 tests/
使用 pytest
不能新增依赖

Step 3:跑基线测试

pytest -q

结果:

1 failed

assert -1 == 5

Step 4:读相关代码

读取:

calculator.py

发现:

return a - b

Step 5:修改

return a + b

Step 6:再次测试

pytest -q

结果:

1 passed

Step 7:Completion Gate

检查:

full_tests_passed = true
tests_modified = false
new_dependency = false

通过。

Step 8:报告

输出:

根因
修改
测试
规则遵守情况

整个流程非常简单。

但已经具备真正 Agent 的核心:

Observation 驱动
Tool 执行
State 更新
Completion Gate
Trace

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
评论 抢沙发
头像-大赛人网
欢迎您留下宝贵的见解!
提交
头像-大赛人网

昵称

取消
昵称

    请登录后查看评论内容