Reviewer.review() 仅对存活的评委样本进行平均处理,因此部分评委失败会缩小分母,并可使一个样本代替 n_sample(ScoreRetryLoop)
作者: shaurya416创建于 2026年9月25日更新于 2026年9月25日
sweagent/agent/reviewer.py:427-443 (类 Reviewer, 方法 review):
for _ in range(self._config.n_sample):
try:
answer = self._model.query(messages)["message"]
except Exception as e:
self.logger.warning(f"Query failed: {e}", exc_info=True)
continue
try:
score = self.interpret(answer)
except ValueError as e:
self.logger.warning(f"Could not interpret response: {answer!r}, got {e}")
continue
answers.append(answer)
accepts.append(score)
if not accepts:
answers = ["No valid scores found, failing submission"]
accepts = [-100.0]
accept = sum(accepts) / len(accepts) - penalty任何失败的评委样本都会被 continue 并从 accepts 中删除。这涵盖了 query() 异常,该异常逃避了模型自己的重试包装器,回复 interpret() (行 400-414) 无法解析,因为最后一行没有数字,以及 score_range 范围外的分数。accept 然后是 sum(accepts) / len(accepts),其中 len(accepts) 是幸存者的数量,而不是配置的 n_sample。代码只有在所有样本都丢失时才会失败(accepts = [-100.0])。部分损失只会缩小分母,因此平均值取决于哪些样本成功。reduce_by_std 罚则(行 445-446)也有同样的问题:当只有一个幸存者时,np.std(accepts) 为 0,罚则消失了。
内容来源: SWE-agent/SWE-agent