Skip to content

fix: hide-older-comments fails to match workflow_id in combined XML marker#18205

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-hide-older-comments
Feb 24, 2026
Merged

fix: hide-older-comments fails to match workflow_id in combined XML marker#18205
pelikhan merged 3 commits intomainfrom
copilot/fix-hide-older-comments

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

hide-older-comments on add-comment safe output never finds previous comments because findCommentsWithTrackerId searches for the standalone <!-- gh-aw-workflow-id: value --> marker, but add_comment.cjs writes the combined XML marker format via generateXMLMarker():

<!-- gh-aw-agentic-workflow: PR Review, engine: copilot, id: 12345, workflow_id: pr-review, run: https://... -->

Changes

  • add_comment.cjsfindCommentsWithTrackerId and findDiscussionCommentsWithTrackerId: Extended the filter to match both marker formats:

    • Standalone (backward-compat): <!-- gh-aw-workflow-id: value -->
    • Combined XML marker: <!-- gh-aw-agentic-workflow: present AND workflow_id: value, or workflow_id: value -->

    Requiring the <!-- gh-aw-agentic-workflow: prefix prevents false positives from arbitrary comment content containing workflow_id:.

  • add_comment.test.cjs: Added a test case covering the combined marker format.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw nonexistent-workinit --limit infocmp -1 xterm-color resolved$ /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha -unreachable=false /tmp/go-build889045531/b096/vet.cfg 045531/b124/vet.cfg a2615bb3240425a6git GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -uns�� -unreachable=false (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha ole.test GO111MODULE rtcfg.link GOINSECURE 6276eff8ca234195rev-parse GOMODCACHE Ey0dPZIRGnmVdmKxI4/X0HLTQaA8PlvKCwosL9U/WoEm3cto5EBHId6yOoQu (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha _.a GO111MODULE Name,createdAt,startedAt,updated-buildmode=exe GOINSECURE GOMOD GOMODCACHE util.test 8904�� snY6xQzyS /tmp/go-build889045531/b036/vet.cfg 045531/b337/vet.cfg GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha -json GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -uns�� -unreachable=false /tmp/go-build889045531/b079/vet.cfg 045531/b335/vet.cfg GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha t0 status (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha 1841555687/.github/workflows cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha -bool -buildtags /usr/bin/git -errorsas -ifaceassert -nilfunc git rev-�� --show-toplevel -tests /usr/bin/git che/go-build/80/git GOPROXY 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel -tests /usr/bin/git -json GO111MODULE x_amd64/vet git rev-�� --git-dir x_amd64/vet /usr/lib/git-core/git -json GO111MODULE x_amd64/vet /usr/lib/git-core/git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha npx prettier --cGOSUMDB GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go sh -c &#34;prettier&#34; --che-errorsas /bin/sh 64/bin/go tierignore (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha che/go-build/75/753173e78fde3733GOINSECURE **/*.cjs 64/bin/go **/*.json --ignore-path ../../../.pretti-unreachable=false go list�� -m -json 64/bin/go --write **/*.cjs 64/bin/go go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha prettier --check 64/bin/go --ignore-path .prettierignore 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha vaScript462678204/001/test-complex-frontmatter-with-tools.md GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile -uns�� _.a /tmp/go-build889045531/b051/vet.cfg 045531/b345/vet.cfg GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha -json GO111MODULE 0/x64/bin/node GOINSECURE GOMOD GOMODCACHE /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet t-ha�� SameOutput1799084311/001/stability-test.md /tmp/go-build889045531/b067/vet.cfg 0/x64/bin/node GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuremote.origin.url (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet stlo�� matter-with-nested-objects.md cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuorigin (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet stlo�� -json cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuTest User (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE 64/pkg/tool/linux_amd64/link GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/link env -json GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path npx prettier --cGOSUMDB GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go node /hom�� --check scripts/**/*.js 64/bin/go .prettierignore (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 github.com/githu-atomic -lang=go1.25 go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuTest User (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha -json GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env 4074668313/.github/workflows cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha -json rty 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet stlo�� matter-with-arrays.md GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go **/*.ts **/*.json --ignore-path go env -json GOMOD 64/bin/go tierignore (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go **/*.ts **/*.json --ignore-path git -c log.showsignatur-errorsas log 64/bin/go -d (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build889045531/b381/cli.test /tmp/go-build889045531/b381/cli.test -test.testlogfile=/tmp/go-build889045531/b381/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE node /opt�� prettier --check 64/bin/go --ignore-path .prettierignore 64/bin/go go (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name npx prettier --cGOSUMDB GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go node /hom�� --check scripts/**/*.js 64/bin/go .prettierignore (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>hide-older-comments on add-comment safe output finds no matching comments despite correct workflow_id marker</issue_title>
<issue_description>## Description

The hide-older-comments: true option on the add-comment safe output does not hide previous comments from the same workflow. The handler runs, searches for previous comments, but finds zero matches — even when prior comments contain the workflow_id in their footer marker.

Reproduction

Workflow source (pr-review.md):

safe-outputs:
  add-comment:
    max: 1
    hide-older-comments: true

gh-aw version: v0.50.0 (also tested after upgrading to v0.50.1 — same behavior)

Steps:

  1. Push to a PR branch to trigger the workflow
  2. Workflow posts a comment with footer: <!-- gh-aw-agentic-workflow: PR Review, engine: copilot, id: ..., workflow_id: pr-review, run: ... -->
  3. Push again to trigger a second run
  4. Second run's safe_outputs job logs show:
    Hide-older-comments is enabled
    Searching for previous comments with workflow ID: pr-review
    No previous comments found with matching workflow ID
    
  5. New comment is created without hiding the previous one
  6. Result: multiple visible, un-minimized PR Review comments accumulate on the PR

Evidence from logs

From the safe_outputs job of run 22360210304:

Safe Output Handler Manager starting...
Loaded config from GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: {"add_comment":{"hide_older_comments":true,"max":1},...}
Hide-older-comments is enabled
...
Adding comment to issue/PR github/gh-aw#1 in dsg-tech/otv-moe-backend
Searching for previous comments with workflow ID: pr-review
No previous comments found with matching workflow ID
Created comment: https://github.com/dsg-tech/otv-moe-backend/pull/1#issuecomment-3953349694

The previous comment (posted at 16:24 UTC by the same workflow) has this footer:

<!-- gh-aw-agentic-workflow: PR Review, engine: copilot, id: 22359671348, workflow_id: pr-review, run: https://github.com/dsg-tech/otv-moe-backend/actions/runs/22359671348 -->

So the workflow_id: pr-review value IS present in the comment body, but the search function doesn't match it.

Suspected root cause

The search function in add_comment.cjs (findCommentsWithTrackerId or similar) appears to search for a standalone marker format (e.g., <!-- gh-aw-workflow-id: pr-review -->) rather than parsing the workflow_id field from within the combined <!-- gh-aw-agentic-workflow: ... --> footer marker that add_comment actually writes.

Compiled lock file confirmation

The compiled lock file correctly includes the config at the handler level:

GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: {"add_comment":{"hide_older_comments":true,"max":1},...}

So the compiler is propagating the setting correctly — the issue is in the runtime comment matching logic.

Expected behavior

When hide-older-comments: true is set, the handler should find and minimize all previous comments from the same workflow before posting a new one.

Environment

  • gh-aw: v0.50.0 and v0.50.1
  • Repo: private enterprise repo
  • Engine: copilot</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix hide older comments option in add-comment output fix: hide-older-comments fails to match workflow_id in combined XML marker Feb 24, 2026
@pelikhan pelikhan marked this pull request as ready for review February 24, 2026 21:05
Copilot AI review requested due to automatic review settings February 24, 2026 21:05
@pelikhan pelikhan merged commit 0bb7503 into main Feb 24, 2026
43 checks passed
@pelikhan pelikhan deleted the copilot/fix-hide-older-comments branch February 24, 2026 21:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes hide-older-comments not finding prior comments by extending workflow ID detection to support both the legacy standalone marker and the newer combined gh-aw-agentic-workflow XML marker format.

Changes:

  • Update comment filtering to match either <!-- gh-aw-workflow-id: ... --> or <!-- gh-aw-agentic-workflow: ..., workflow_id: ..., ... -->.
  • Apply the same marker-matching logic to both issue/PR comments (REST) and discussion comments (GraphQL).
  • Add a test covering the combined marker format for the issue/PR comment path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
actions/setup/js/add_comment.cjs Expands workflow marker matching logic so hide-older-comments can find comments that only include workflow_id inside the combined XML marker.
actions/setup/js/add_comment.test.cjs Adds a regression test proving minimization triggers when old comments use the combined XML marker format.
Comments suppressed due to low confidence (2)

actions/setup/js/add_comment.cjs:86

  • The marker-matching predicate is now duplicated (and slightly complex) in both findCommentsWithTrackerId and findDiscussionCommentsWithTrackerId. Consider extracting a shared helper (e.g., commentHasWorkflowMarker(body, workflowId)) and reusing it in both places to prevent the two implementations from drifting as marker formats evolve.
    // Filter comments that contain the workflow-id and are NOT reaction comments.
    // Supports both the standalone marker format (<!-- gh-aw-workflow-id: value -->)
    // and the combined XML marker format (<!-- gh-aw-agentic-workflow: ..., workflow_id: value, ... -->).
    const filteredComments = data
      .filter(comment => {
        if (!comment.body || comment.body.includes(`<!-- gh-aw-comment-type: reaction -->`)) return false;
        // Standalone marker: <!-- gh-aw-workflow-id: value -->
        if (comment.body.includes(`<!-- gh-aw-workflow-id: ${workflowId} -->`)) return true;
        // Combined XML marker: <!-- gh-aw-agentic-workflow: ..., workflow_id: value, ... -->
        if (comment.body.includes(`<!-- gh-aw-agentic-workflow:`) && (comment.body.includes(`workflow_id: ${workflowId},`) || comment.body.includes(`workflow_id: ${workflowId} -->`))) return true;
        return false;
      })

actions/setup/js/add_comment.cjs:149

  • findDiscussionCommentsWithTrackerId was updated to support the combined gh-aw-agentic-workflow marker format, but add_comment.test.cjs only adds coverage for the REST issue/PR comment path. Please add a test exercising the discussion path (GraphQL discussion comments + minimizeComment) with a combined marker so regressions in discussions are caught too.
    const filteredComments = result.repository.discussion.comments.nodes
      .filter(comment => {
        if (!comment.body || comment.body.includes(`<!-- gh-aw-comment-type: reaction -->`)) return false;
        // Standalone marker: <!-- gh-aw-workflow-id: value -->
        if (comment.body.includes(`<!-- gh-aw-workflow-id: ${workflowId} -->`)) return true;
        // Combined XML marker: <!-- gh-aw-agentic-workflow: ..., workflow_id: value, ... -->
        if (comment.body.includes(`<!-- gh-aw-agentic-workflow:`) && (comment.body.includes(`workflow_id: ${workflowId},`) || comment.body.includes(`workflow_id: ${workflowId} -->`))) return true;
        return false;
      })
      .map(({ id, body }) => ({ id, body }));

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hide-older-comments on add-comment safe output finds no matching comments despite correct workflow_id marker

3 participants