fix(swebench): 真实仓 patch 捕获 + agent 稳定性

#1 稳定性:HEARTBEAT_TIMEOUT 30→120(可配 AGENT_HEARTBEAT_TIMEOUT)——真实仓 clone/长
模型调用不再误杀 agent。
#2 正确性/忠实度:
- 透传 GIT_BASE_COMMIT;agent clone 改为浅 fetch+checkout 该 commit(在正确基线上读/改,
  且大仓也快);emit_patch 持久化 base_commit + _git_diff 对 SHA 走浅 fetch。
- agent 读文件预算可配并调大(AGENT_CTX_MAX_FILES=40/BYTES=40000),LLM 看到完整文件,
  避免全量重写截断 → diff 失真。launcher 透传这些 env 给 agent pod。

import + runtime-contract/result-aggregator/security-boundary 测试全绿。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
gongzhiyong
2026-06-22 00:25:38 +08:00
co-authored by Claude Opus 4.8
parent 74f5ce2f97
commit fb1eeeebfa
7 changed files with 72 additions and 14 deletions
+4
View File
@@ -737,6 +737,10 @@ Return ONLY JSON:
return sorted(files)
def _collect_workspace_context(self, max_files: int = 20, max_bytes_per_file: int = 6000) -> dict[str, str]:
# Real-repo edits need the FULL file (the LLM rewrites complete content; truncated input →
# truncated/hallucinated rewrite → wrong diff). Raise budgets, env-tunable for big repos.
max_files = int(os.getenv("AGENT_CTX_MAX_FILES", str(max_files)))
max_bytes_per_file = int(os.getenv("AGENT_CTX_MAX_BYTES", str(max_bytes_per_file)))
root = Path(self.workspace_dir)
if not root.exists():
return {}