From bf61a39cb5c48f2f11fcdde983cdfa8154cc98dd Mon Sep 17 00:00:00 2001 From: lefarcen <935902669@qq.com> Date: Wed, 27 May 2026 20:30:05 +0800 Subject: [PATCH] ci: clean agent report (write-to-file) + slim artifacts/uploads (#3116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: clean agent report (write-to-file) + slim artifacts/uploads Four related cleanups to the agent PR exploration output: 1. Clean report. The PR comment / report.md was assembled by dumping the entire verbose expect.log (ACP init logs, "Git failed" warnings, the ~24KB echoed prompt, ANSI codes, progress checklist) under the trace header -- ~28KB of noise. Instead, instruct the agent to write its final Markdown report to a file via its file-write tool, and have the runner read that file directly. Verified: Codex writes a clean report to the given absolute path. Falls back to an inconclusive note if the agent did not finish. 2. Drop duplicate trace/video. The script copied playwright-smoke-trace.zip -> playwright-trace.zip (a ~28MB legacy duplicate) and the webm likewise, and uploaded both to R2. Keep only the canonical smoke-named artifacts. 3. Slim the GitHub artifact. The trace zips and videos are already on R2; exclude *.zip / *.webm from the uploaded artifact so it drops from ~56MB to <1MB (report + logs only). 4. Persist report on the runner. Copy the report / agent-report / expect.log / trace URL to a stable host dir ($HOME/.cache/agent-pr-explore/reports/pr-) so dry runs (skip_comment) can be inspected without downloading the artifact. Co-Authored-By: Claude Opus 4.7 (1M context) * ci: address review — keep advisory reports + recursive artifact excludes Review findings on the report/artifact cleanup: 1. Regression fix: the non-app-surface and deterministic-verifier branches write their pre-baked advisory report (Inconclusive / Pass / Fail) and never run the agent, so they don't produce agent-report.md. After switching write_agent_report_artifact to read only agent-report.md they fell through to the "agent did not write a final report" fallback, dropping the real advisory (and mis-reporting on .github-only PRs like this one). Fix: those branches now write their advisory directly to $agent_report_file — single source of truth for the report body. 2. Recursive artifact excludes: the source Playwright recording lives at artifacts/playwright-video/.webm; non-recursive !*.webm / !*.zip didn't match the subdirectory. Use **/*.zip and **/*.webm so the slim actually holds. 3. Drop the now-dangling summary.legacyTrace field (the legacy trace copy is no longer produced), matching the legacyVideo removal. Co-Authored-By: Claude Opus 4.7 (1M context) --------- Co-authored-by: Claude Opus 4.7 (1M context) --- .github/scripts/agent-pr-explore-sandbox.sh | 43 ++++++++++--------- .../workflows/agent-pr-explore-sandbox.yml | 7 ++- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/.github/scripts/agent-pr-explore-sandbox.sh b/.github/scripts/agent-pr-explore-sandbox.sh index d77c31236..dd75ed578 100755 --- a/.github/scripts/agent-pr-explore-sandbox.sh +++ b/.github/scripts/agent-pr-explore-sandbox.sh @@ -52,6 +52,7 @@ context_file="$artifacts/pr-context.md" trimmed_context_file="$artifacts/pr-context-trimmed.md" changed_files_file="$artifacts/changed-files.txt" fixture_instructions_file="$artifacts/fixture-instructions.md" +agent_report_file="$artifacts/agent-report.md" playwright_video_dir="$artifacts/playwright-video" rm -rf "$root" mkdir -p "$artifacts" "$pnpm_store" "$playwright_video_dir" @@ -674,7 +675,6 @@ function writeTraceViewerFiles(viewerUrl) { ok: false, video: null, trace: "playwright-smoke-trace.zip", - legacyTrace: "playwright-trace.zip", traceViewerUrl: viewerUrl || null, }; @@ -686,19 +686,11 @@ function writeTraceViewerFiles(viewerUrl) { await context.close(); await browser.close(); } - const smokeTrace = path.join(artifacts, "playwright-smoke-trace.zip"); - if (fs.existsSync(smokeTrace)) { - fs.copyFileSync(smokeTrace, path.join(artifacts, "playwright-trace.zip")); - } - const videos = fs.readdirSync(videoDir).filter((name) => name.endsWith(".webm")); if (videos.length > 0) { const source = path.join(videoDir, videos[0]); - const stable = path.join(artifacts, "playwright-smoke-session.webm"); - fs.copyFileSync(source, stable); - fs.copyFileSync(source, path.join(artifacts, "playwright-session.webm")); + fs.copyFileSync(source, path.join(artifacts, "playwright-smoke-session.webm")); summary.video = "playwright-smoke-session.webm"; - summary.legacyVideo = "playwright-session.webm"; } writeTraceViewerFiles(viewerUrl); fs.writeFileSync(path.join(artifacts, "playwright-recording-summary.json"), JSON.stringify(summary, null, 2)); @@ -847,9 +839,7 @@ async function putObject(filePath, key, contentType, cacheControl) { requireConfig(); const files = [ ["playwright-smoke-trace.zip", "application/zip", "public, max-age=604800"], - ["playwright-trace.zip", "application/zip", "public, max-age=604800"], ["playwright-smoke-session.webm", "video/webm", "public, max-age=604800"], - ["playwright-session.webm", "video/webm", "public, max-age=604800"], ["playwright-initial.png", "image/png", "public, max-age=604800"], ["playwright-final.png", "image/png", "public, max-age=604800"], ["expect.log", "text/plain; charset=utf-8", "public, max-age=604800"], @@ -913,12 +903,14 @@ write_agent_report_artifact() { echo "Trace artifact was not generated for this run." fi echo - if [ -f "$artifacts/expect.log" ]; then - cat "$artifacts/expect.log" + if [ -s "$agent_report_file" ]; then + # The agent wrote its clean Markdown report to this file directly. + cat "$agent_report_file" else echo "### ⚠️ Verdict: Inconclusive" echo - echo "The runner did not produce an exploration report." + echo "The agent did not write a final report (it may have hit the run" + echo "timeout before finishing). See the run log artifact / \`expect.log\` for details." fi } > "$artifacts/agent-pr-exploration-report.md" } @@ -1181,7 +1173,7 @@ seed_agent_fixture "$agent_fixture" if [ "$deterministic_verifier" = "web-static-export" ] && [ "$browser_exploration_needed" != "true" ]; then verifier_status="$(cat "$artifacts/deterministic-verifier-exit-code.txt" 2>/dev/null || echo 1)" if [ "$verifier_status" = "0" ]; then - cat > "$artifacts/expect.log" < "$agent_report_file" < "$artifacts/expect.log" < "$agent_report_file" < "$artifacts/expect.log" < "$agent_report_file" < "$artifacts/docker.log" 2>&1 || true + +# Persist the report + trace pointer to a stable host dir so dry/validation runs +# (skip_comment) can be inspected without downloading the slow, large workflow +# artifact. Overwrites per PR; the big trace zip stays on R2 only. +report_persist_dir="${OD_SANDBOX_REPORT_DIR:-$HOME/.cache/agent-pr-explore/reports}/pr-${PR_NUMBER}" +mkdir -p "$report_persist_dir" 2>/dev/null || true +cp -f "$artifacts/agent-pr-exploration-report.md" "$report_persist_dir/report.md" 2>/dev/null || true +cp -f "$artifacts/agent-report.md" "$report_persist_dir/agent-report.md" 2>/dev/null || true +cp -f "$artifacts/expect.log" "$report_persist_dir/expect.log" 2>/dev/null || true +cp -f "$artifacts/playwright-trace-viewer.txt" "$report_persist_dir/trace-url.txt" 2>/dev/null || true +echo "Report persisted on runner: $report_persist_dir" diff --git a/.github/workflows/agent-pr-explore-sandbox.yml b/.github/workflows/agent-pr-explore-sandbox.yml index 4c9c81e39..bd99f83cd 100644 --- a/.github/workflows/agent-pr-explore-sandbox.yml +++ b/.github/workflows/agent-pr-explore-sandbox.yml @@ -127,7 +127,12 @@ jobs: uses: actions/upload-artifact@v7 with: name: agent-pr-explore-sandbox-${{ steps.pr.outputs.number }}-${{ steps.pr.outputs.head_sha }} - path: ${{ runner.temp }}/agent-pr-explore-sandbox/artifacts/ + # The trace zips (~28MB) and videos are already published to R2; keep + # them out of the GitHub artifact so it stays small (report + logs). + path: | + ${{ runner.temp }}/agent-pr-explore-sandbox/artifacts/ + !${{ runner.temp }}/agent-pr-explore-sandbox/artifacts/**/*.zip + !${{ runner.temp }}/agent-pr-explore-sandbox/artifacts/**/*.webm if-no-files-found: warn retention-days: 7