Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .github/workflows/qwen-code-pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,20 @@ jobs:
pull-requests: 'write'
issues: 'write'
steps:
# Self-hosted runners reuse the workspace, so an interrupted review can
# leave a stale `.qwen/tmp/review-pr-*` worktree or `qwen-review/*` branch
# that trips the checkout below. Prune defensively; never fail the job.
- name: 'Clean stale review worktrees'
# Self-hosted runners reuse $HOME, /tmp and the workspace, so a prior run
# can bleed into this one: its agent session/memory (under QWEN_HOME),
# leftover draft comments (/tmp/stage-*.md, which survive `git clean`), or
# a stale `.qwen/tmp/review-pr-*` worktree / `qwen-review/*` branch from an
# interrupted review. Reset all three per run; never fail the job.
- name: 'Clean stale agent state'
run: |-
set -uo pipefail
# Fresh per-run agent home (must match QWEN_HOME on the Qwen step
# below) + drop any leftover stage drafts.
QWEN_HOME="${RUNNER_TEMP:?}/qwen-home"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] QWEN_HOME path coupling relies only on comments. The cleanup step computes QWEN_HOME="${RUNNER_TEMP:?}/qwen-home" as a shell variable that evaporates when the run: block exits, while the qwen step uses ${{ runner.temp }}/qwen-home as an independent GitHub Actions expression. The string literal qwen-home is duplicated in 4 locations across 2 files with only "must match" comments as coupling.

Consider using step outputs to make the coupling mechanical:

- id: 'agent-state'
  name: 'Clean stale agent state'
  run: |-
    set -uo pipefail
    QWEN_HOME="${RUNNER_TEMP:?}/qwen-home"
    echo "qwen_home=${QWEN_HOME}" >> "$GITHUB_OUTPUT"
    rm -rf "$QWEN_HOME" 2>/dev/null || true
    mkdir -p "$QWEN_HOME"
    # ... rest of cleanup

Then in the Qwen step env:

QWEN_HOME: '${{ steps.agent-state.outputs.qwen_home }}'

— qwen3.7-max via Qwen Code /review

rm -rf "$QWEN_HOME" 2>/dev/null || true

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] rm -rf "$QWEN_HOME" destroys the entire QWEN_HOME including potential bin/, skills/, extensions/ caches on every run. This is broader than the stated intent ("session/memory cannot leak").

If isolation of session and memory is the goal, consider targeted cleanup:

rm -rf "$QWEN_HOME/projects" "$QWEN_HOME/sessions" 2>/dev/null || true

This preserves bin/, skills/, extensions/ caches across runs while still preventing session/memory bleed. Alternatively, add a comment explaining cache destruction is intentional.

— qwen3.7-max via Qwen Code /review

mkdir -p "$QWEN_HOME"
rm -f /tmp/stage-*.md 2>/dev/null || true
# `.git` is a directory in a normal checkout but a gitlink file in a
# worktree; -e covers both, and a missing .git (first run) too.
if [ ! -e .git ]; then
Expand Down Expand Up @@ -409,6 +417,10 @@ jobs:
PR_NUMBER: '${{ steps.context.outputs.pr_number }}'
REVIEW_MODE: '${{ steps.context.outputs.review_mode }}'
TIMEOUT_MINUTES: '${{ steps.context.outputs.timeout_minutes }}'
# Per-run agent home so this review's session/memory cannot leak into
# the next on the reused self-hosted workspace (reset in "Clean stale
# agent state"). Must match the QWEN_HOME computed there.
QWEN_HOME: '${{ runner.temp }}/qwen-home'
run: |-
set -euo pipefail
fail() {
Expand Down
24 changes: 18 additions & 6 deletions .github/workflows/qwen-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,21 @@ jobs:
-f content='eyes' > /dev/null ||
echo "Failed to add triage acknowledgement reaction; continuing." >&2

# Self-hosted ECS runners reuse the workspace between runs, so an
# interrupted triage (its agent has enter_worktree/exit_worktree) can
# leave a stale `.qwen/tmp/*` worktree that trips the checkout below.
# Prune defensively; never fail the job. No-op on a fresh hosted runner.
- name: 'Clean stale triage worktrees'
# Self-hosted ECS runners reuse $HOME, /tmp and the workspace between runs,
# so a prior run can bleed into this one: its agent session/memory (under
# QWEN_HOME), leftover draft comments (/tmp/stage-*.md, which survive
# `git clean`), or a stale `.qwen/tmp/*` worktree from an interrupted
# triage (its agent has enter_worktree/exit_worktree). Reset all three
# per run; never fail the job. No-op on a fresh hosted runner.
- name: 'Clean stale agent state'
run: |-
set -uo pipefail
# Fresh per-run agent home (must match QWEN_HOME on the Qwen step
# below) + drop any leftover stage drafts.
QWEN_HOME="${RUNNER_TEMP:?}/qwen-home"
rm -rf "$QWEN_HOME" 2>/dev/null || true
mkdir -p "$QWEN_HOME"
rm -f /tmp/stage-*.md 2>/dev/null || true
# `.git` is a directory in a normal checkout but a gitlink file in a
# worktree; -e covers both, and a missing .git (first run) too.
if [ ! -e .git ]; then
Expand All @@ -210,7 +218,7 @@ jobs:
fi
rm -rf .qwen/tmp/* 2>/dev/null || true
git worktree prune -v || true
echo "stale triage worktrees cleaned"
echo "stale agent state cleaned"

- name: 'Checkout repo'
uses: 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd' # v6.0.2
Expand All @@ -234,6 +242,10 @@ jobs:
GITHUB_TOKEN: '${{ secrets.QWEN_CODE_BOT_TOKEN || secrets.CI_BOT_PAT }}'
GH_TOKEN: '${{ secrets.QWEN_CODE_BOT_TOKEN || secrets.CI_BOT_PAT }}'
REPOSITORY: '${{ github.repository }}'
# Per-run agent home so this run's session/memory cannot leak into the
# next on the reused self-hosted workspace (reset in "Clean stale
# agent state"). Must match the QWEN_HOME computed there.
QWEN_HOME: '${{ runner.temp }}/qwen-home'
with:
OPENAI_API_KEY: '${{ secrets.OPENAI_API_KEY }}'
OPENAI_BASE_URL: '${{ secrets.OPENAI_BASE_URL }}'
Expand Down
Loading