From 1e72b9bcbaee71e55b2a8971e7be30ee5e288701 Mon Sep 17 00:00:00 2001 From: ffaerber Date: Wed, 8 Jul 2026 09:34:40 +0200 Subject: [PATCH] fix: skip framework reply when the agent self-posted on the thread --- .gitea/workflows/scripts/publish.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/scripts/publish.sh b/.gitea/workflows/scripts/publish.sh index 8effabe..8fa3fc2 100755 --- a/.gitea/workflows/scripts/publish.sh +++ b/.gitea/workflows/scripts/publish.sh @@ -195,7 +195,25 @@ if [ "$MODE" != "pr" ]; then done < /tmp/subtasks.txt subtext=$(printf '\n\n---\nCreated sub-issues%s (mention an agent on each when ready):%b' "${ms:+ under milestone **$ms**}" "$links") fi - post "$(printf '%s%s%s' "$msg" "$subtext" "$activity")" + # DEDUP GUARD (issue: @pm double-posts its report). Prompt-level "do not self-post" is ignored + # by some models, so enforce it here: if the agent ALREADY posted a comment on this thread + # during the run (any comment by $NAME newer than the pre-run newest id from fetch-thread.sh), + # its self-post IS the reply — skip the duplicate framework comment. Markers (CLOSE_ISSUE, + # DELEGATE, MERGE_PR, subtasks) were already processed above and are unaffected. + pre_cid=$(cat /tmp/thread_max_cid 2>/dev/null || echo 0) + : > /tmp/all_comments.json + for pg in $(seq 1 10); do + cpg=$(curl -sS "${hdr[@]}" "$API/issues/$NUM/comments?limit=50&page=$pg" 2>/dev/null) || cpg='[]' + cn=$(printf '%s' "$cpg" | jq 'if type=="array" then length else 0 end' 2>/dev/null || echo 0) + [ "${cn:-0}" -gt 0 ] && printf '%s\n' "$cpg" >> /tmp/all_comments.json + [ "${cn:-0}" -lt 50 ] && break + done + selfposts=$(jq -rs --arg n "$NAME" --argjson c "${pre_cid:-0}" '[ (add // [])[] | select(.user.login==$n) | select(.id > $c) ] | length' /tmp/all_comments.json 2>/dev/null || echo 0) + if [ "${selfposts:-0}" -gt 0 ]; then + echo "agent @$NAME already posted ${selfposts} comment(s) on #$NUM during this run — skipping duplicate framework reply" + else + post "$(printf '%s%s%s' "$msg" "$subtext" "$activity")" + fi # --- @pm autopilot merge: @pm is the ONLY agent that merges, and ONLY under the autopilot label --- # (@qa never merges — it approves and hands back here.) Merge with the PAT (TTOK), not the built-in