Problem
When a workflow triggered by workflow_dispatch posts a comment to a Discussion via add-comment, the comment is always top-level. There's no way for the agent to specify which comment to thread under.
The replyToId logic in add_comment.cjs (line 593) only works for discussion_comment-triggered workflows:
const replyToId = context.eventName === "discussion_comment" && !hasExplicitItemNumber
? await resolveTopLevelDiscussionCommentId(githubClient, context.payload?.comment?.node_id)
: null;
This means any workflow triggered via dispatch-workflow — even one that receives a parent comment node ID as an input — cannot thread its reply.
Use case
We run a multi-level compliance agent system (CentralRepoOps pattern). When a reviewer posts /feedback on a specialist's Discussion comment:
- Feedback workflow (triggered by
discussion_comment) parses the command and identifies the specialist
- Feedback workflow dispatches the specialist via
dispatch-workflow with the target repo and context
- Specialist re-evaluates and posts a
🔄 Updated reply to the Discussion
Step 3 always produces a top-level comment because the specialist runs under workflow_dispatch. The reviewer has to scroll to find it, and the Discussion thread becomes hard to follow.
We can already pass the parent comment node_id through dispatch inputs to the specialist — we just need a way for the specialist to hand it to the add-comment handler.
Proposed solution
Add optional reply_to_id field to the add-comment agent output message:
{
"type": "add_comment",
"item_number": 240,
"body": "🔄 Updated finding...",
"reply_to_id": "DC_kwDOParentComment456"
}
In add_comment.cjs, the handler would check message.reply_to_id when the event is NOT discussion_comment (or as a user-specified override):
const replyToId = context.eventName === "discussion_comment" && !hasExplicitItemNumber
? await resolveTopLevelDiscussionCommentId(githubClient, context.payload?.comment?.node_id)
: (message.reply_to_id || null);
The resolveTopLevelDiscussionCommentId helper should also be applied to message.reply_to_id to handle cases where the caller passes a reply node ID instead of a top-level one.
Context
Problem
When a workflow triggered by
workflow_dispatchposts a comment to a Discussion viaadd-comment, the comment is always top-level. There's no way for the agent to specify which comment to thread under.The
replyToIdlogic inadd_comment.cjs(line 593) only works fordiscussion_comment-triggered workflows:This means any workflow triggered via
dispatch-workflow— even one that receives a parent comment node ID as an input — cannot thread its reply.Use case
We run a multi-level compliance agent system (CentralRepoOps pattern). When a reviewer posts
/feedbackon a specialist's Discussion comment:discussion_comment) parses the command and identifies the specialistdispatch-workflowwith the target repo and context🔄 Updated replyto the DiscussionStep 3 always produces a top-level comment because the specialist runs under
workflow_dispatch. The reviewer has to scroll to find it, and the Discussion thread becomes hard to follow.We can already pass the parent comment
node_idthrough dispatch inputs to the specialist — we just need a way for the specialist to hand it to theadd-commenthandler.Proposed solution
Add optional
reply_to_idfield to theadd-commentagent output message:In
add_comment.cjs, the handler would checkmessage.reply_to_idwhen the event is NOTdiscussion_comment(or as a user-specified override):The
resolveTopLevelDiscussionCommentIdhelper should also be applied tomessage.reply_to_idto handle cases where the caller passes a reply node ID instead of a top-level one.Context
discussion_commenttriggers)workflow_dispatch-triggered workflows that know their target comment