# 使用 SWE-bench 格式处理多个问题
cat > /workspace/sweagent/batch_issues.json << 'EOF'
[
{
"repo": "USER/REPO",
"issue_number": 1,
"model": "claude-sonnet-4-20250514"
},
{
"repo": "USER/REPO",
"issue_number": 2,
"model": "claude-sonnet-4-20250514"
}
]
EOF
# 批量运行脚本
cat > /workspace/sweagent/run_batch.sh << 'BASH'
#!/bin/bash
set -e
ISSUES_FILE="${1:-/workspace/sweagent/batch_issues.json}"
OUTPUT_DIR="/workspace/sweagent/output"
ENV_FILE="/workspace/sweagent/.env"
echo "开始批量 SWE-agent 运行..."
python3 -c "
import json
issues = json.load(open('$ISSUES_FILE'))
for i, issue in enumerate(issues):
print(f'Issue {i+1}/{len(issues)}: {issue[\"repo\"]}#{issue[\"issue_number\"]}')
"
jq -c '.[]' "$ISSUES_FILE" | while read issue; do
REPO=$(echo "$issue" | jq -r '.repo')
ISSUE_NUM=$(echo "$issue" | jq -r '.issue_number')
MODEL=$(echo "$issue" | jq -r '.model')
echo "=== 处理: $REPO#$ISSUE_NUM 使用 $MODEL ==="
docker run --rm \
--env-file "$ENV_FILE" \
-v "$OUTPUT_DIR:/output" \
-v /var/run/docker.sock:/var/run/docker.sock \
sweagent/swe-agent:latest \
python run.py \
--agent.model.name="$MODEL" \
--agent.model.per_instance_cost_limit=2.00 \
--env.repo.github_url="https://github.com/$REPO" \
--problem_statement.github_url="https://github.com/$REPO/issues/$ISSUE_NUM" \
--output_dir=/output || echo "失败: $REPO#$ISSUE_NUM"
done
echo "批量完成。结果位于 $OUTPUT_DIR"
BASH
chmod +x /workspace/sweagent/run_batch.sh
/workspace/sweagent/run_batch.sh