Skip to content

add_comment: reply to pull_request_review_comment in the review thread, not at PR level #27773

@yskopets

Description

@yskopets

Summary

When a workflow is triggered by a pull_request_review_comment event, the agent's response via add_comment is posted as a top-level PR issue comment rather than as a reply in the inline review thread where the original comment appeared.

Expected behaviour

When the triggering event is a pull_request_review_comment, add_comment (with no explicit item_number) should post the response as a reply to the triggering review comment thread using POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/replies, so the reply appears inline next to the code that was commented on.

Current behaviour

add_comment always posts via POST /repos/{owner}/{repo}/issues/{issue_number}/comments, which creates a top-level PR-level comment. The reply appears disconnected from the inline code review thread that triggered the workflow.

Root cause

The add_comment handler doesn't distinguish between triggering event types. The reply_to_id parameter only handles GitHub Discussion threading and is explicitly documented as "ignored for issue and pull request comments". There is no code path that calls the PR review comment reply endpoint.

Suggested fix

When the triggering event is pull_request_review_comment and no explicit item_number is provided, detect this case in the add_comment handler and post via the review comment reply endpoint instead:

// POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/replies
await octokit.request(
  'POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/replies',
  { owner, repo, comment_id: triggeringCommentId, body }
)

This would make the agent's response appear inline in the review thread, matching the user's expectation when they write a /slash-command on a specific line of code.


Filed by Claude Code

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions