diff --git a/.gitea/workflows/scripts/fetch-thread.sh b/.gitea/workflows/scripts/fetch-thread.sh index 0956bb3..e1adda6 100755 --- a/.gitea/workflows/scripts/fetch-thread.sh +++ b/.gitea/workflows/scripts/fetch-thread.sh @@ -26,3 +26,9 @@ jq -rs ' "### comment by \($who):\n\(.body | gsub("\\s*"; ""))\n"' \ /tmp/thread_pages.json > /tmp/thread.md 2>/dev/null || : > /tmp/thread.md echo "thread comments fetched: $(grep -c '^### comment by ' /tmp/thread.md 2>/dev/null || echo 0) (newest 100 kept)" + +# Record the newest comment id on the thread BEFORE the agent runs. publish.sh compares against +# it to detect an agent that self-posted its reply mid-run (via the gitea-api skill, despite the +# prompt telling it not to) and skips the duplicate framework reply. Ids are monotonic — no dates. +jq -rs '[ (add // [])[].id ] | max // 0' /tmp/thread_pages.json > /tmp/thread_max_cid 2>/dev/null || echo 0 > /tmp/thread_max_cid +echo "pre-run newest comment id: $(cat /tmp/thread_max_cid)"