fix: skip framework reply when the agent self-posted on the thread
ci / lint (push) Skipped
ci / lint (pull_request) Successful in 10s
ci / lint (push) Skipped
ci / lint (pull_request) Successful in 10s
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user