Skip to content

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

@Nikhil-Anand-DSG

Description

@Nikhil-Anand-DSG

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 #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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions