From bac7ea5e208eaca9fdfdf92c075975869079a573 Mon Sep 17 00:00:00 2001 From: tulga-bytes Date: Fri, 9 Jan 2026 19:41:57 +0000 Subject: [PATCH 1/2] fix: ensure agent responses are replies to triggering comments ## Summary Updated the prompt and code to ensure that when the action is triggered by a user comment, the agent's responses are actual **replies** to that specific comment rather than standalone comments. ## Changes - Updated `src/utils/prompt.ts` with explicit instructions for the agent to reply to comments using the triggering comment ID - Added `commentId` to `AuggieParams` type in `src/utils/index.ts` - Pass `commentId` through `src/index.ts` to `runAuggie` - Include triggering comment ID in the prompt context in `src/auggie.ts` ## Why Previously, the agent would sometimes create regular comments instead of threaded replies, making conversations harder to follow. This change ensures consistent behavior where responses appear as replies to the original triggering comment. --- src/auggie.ts | 9 +++++++++ src/index.ts | 2 ++ src/utils/index.ts | 3 +++ src/utils/prompt.ts | 16 +++++++++++++--- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/auggie.ts b/src/auggie.ts index bdb0d59..bdf8070 100644 --- a/src/auggie.ts +++ b/src/auggie.ts @@ -14,6 +14,8 @@ export type RunAuggieOptions = { context?: GithubPullRequest; /** The body of the comment that triggered this action, if triggered by a comment */ commentBody?: string; + /** The ID of the comment that triggered this action, if triggered by a comment */ + commentId?: number; }; /** @@ -27,6 +29,7 @@ export async function runAuggie(options: RunAuggieOptions): Promise { workspaceRoot, context, commentBody, + commentId, } = options; const workspace = workspaceRoot || process.cwd(); @@ -70,6 +73,12 @@ export async function runAuggie(options: RunAuggieOptions): Promise { core.info("📨 User comment included in prompt"); } + // Add triggering comment ID if available + if (commentId) { + fullPrompt = `${fullPrompt}\n\n## Triggering Comment ID:\n${commentId}`; + core.info(`📍 Triggering comment ID: ${commentId}`); + } + // Add user prompt fullPrompt = `${fullPrompt}\n\n${userPrompt}`; diff --git a/src/index.ts b/src/index.ts index 27a9bf6..e35f1b2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,6 +19,7 @@ async function main(): Promise { augmentApiUrl, workspaceRoot, commentBody, + commentId, } = getAuggieParams(); const { owner, repo } = parseRepository(); const githubToken = process.env.GITHUB_TOKEN; @@ -34,6 +35,7 @@ async function main(): Promise { apiUrl: augmentApiUrl, workspaceRoot: workspaceRoot || undefined, commentBody, + commentId, }); core.info("✅ Auggie agent completed successfully"); diff --git a/src/utils/index.ts b/src/utils/index.ts index fcdbca0..ed29d6e 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -169,6 +169,7 @@ type AuggieParams = { augmentApiUrl: string; workspaceRoot: string | undefined; commentBody: string | undefined; + commentId: number | undefined; }; /** @@ -189,6 +190,7 @@ export function getAuggieParams(): AuggieParams { const augmentApiUrl = getInput("augment_api_url", true); const workspaceRoot = getInput("workspace_root"); const commentBody = getCommentBodyFromEvent(); + const commentId = getCommentIdFromEvent(); return { eventName, prompt, @@ -196,5 +198,6 @@ export function getAuggieParams(): AuggieParams { augmentApiUrl, workspaceRoot, commentBody, + commentId, } } diff --git a/src/utils/prompt.ts b/src/utils/prompt.ts index 4926356..e0e32dd 100644 --- a/src/utils/prompt.ts +++ b/src/utils/prompt.ts @@ -6,11 +6,21 @@ Important: How you handle changes depends on the context: - If you are working on a Pull Request (PR): You are allowed to commit directly to that PR's branch. - If you are working on a GitHub Issue: You must create a new branch and open a Pull Request with your changes. +CRITICAL - Replying to Comments: +When this action is triggered by a user comment, you MUST reply to that specific comment (not create a new standalone comment). +- A "Triggering Comment ID" will be provided in the prompt context. +- Use this comment ID to create a REPLY to that comment using the GitHub API. +- For issue comments: Use POST /repos/{owner}/{repo}/issues/comments/{comment_id}/replies or reference the comment in your reply. +- For PR review comments: Use POST /repos/{owner}/{repo}/pulls/{pull_number}/comments with the \`in_reply_to\` parameter set to the triggering comment ID. +- This ensures your response appears as a threaded reply to the user's original comment, making the conversation easy to follow. +- If no triggering comment ID is provided, you may create a new comment. + Your workflow: -1. Add a comment to the PR letting the user know you're starting to work on it. +1. Reply to the triggering comment to let the user know you're starting to work on it. + - IMPORTANT: Use the Triggering Comment ID to reply directly to that comment (see above). 2. Read the PR context and understand the request. 3. Create a Todo List: - - Update the original comment on the PR with a todo list of what you're going to do. (Use the github-api tool to update the comment. Replace the initial message with the todo list.) + - Update your reply comment with a todo list of what you're going to do. (Use the github-api tool to update your reply comment.) - Use your GitHub comment to maintain a detailed task list based on the request. - Format todos as a checklist (- [ ] for incomplete, - [x] for complete). - Update the comment with each task completion. @@ -29,7 +39,7 @@ Your workflow: - Files modified - Links to PRs/commits 5. Final Comment Update (IMPORTANT): - - When you are completely done with all tasks, update the original comment ONE FINAL TIME. + - When you are completely done with all tasks, update your reply comment ONE FINAL TIME. - REMOVE the entire task list/checklist from the comment. - Replace the comment body with ONLY a concise, minimal final summary. - Keep it brief: just state what was attempted and what was done. From 2e2096cafa270ac1f271db92e75ae554a1eb0a24 Mon Sep 17 00:00:00 2001 From: tulga-bytes Date: Fri, 9 Jan 2026 20:00:18 +0000 Subject: [PATCH 2/2] Fix: Correct GitHub API instructions for comment responses Address review feedback: GitHub issue/PR timeline comments don't support threaded replies. Updated the agent prompt to: - Remove reference to non-existent /issues/comments/{id}/replies endpoint - Clarify that issue comments require creating new comments with references - Keep in_reply_to for PR review comments (which do support threading) - Update workflow instructions to be consistent with correct API usage --- src/utils/prompt.ts | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/utils/prompt.ts b/src/utils/prompt.ts index e0e32dd..506e4a4 100644 --- a/src/utils/prompt.ts +++ b/src/utils/prompt.ts @@ -6,21 +6,31 @@ Important: How you handle changes depends on the context: - If you are working on a Pull Request (PR): You are allowed to commit directly to that PR's branch. - If you are working on a GitHub Issue: You must create a new branch and open a Pull Request with your changes. -CRITICAL - Replying to Comments: -When this action is triggered by a user comment, you MUST reply to that specific comment (not create a new standalone comment). +CRITICAL - Responding to Comments: +When this action is triggered by a user comment, you should acknowledge the triggering comment in your response. - A "Triggering Comment ID" will be provided in the prompt context. -- Use this comment ID to create a REPLY to that comment using the GitHub API. -- For issue comments: Use POST /repos/{owner}/{repo}/issues/comments/{comment_id}/replies or reference the comment in your reply. -- For PR review comments: Use POST /repos/{owner}/{repo}/pulls/{pull_number}/comments with the \`in_reply_to\` parameter set to the triggering comment ID. -- This ensures your response appears as a threaded reply to the user's original comment, making the conversation easy to follow. -- If no triggering comment ID is provided, you may create a new comment. +- Use the github-api tool to interact with GitHub. + +How to respond depends on the comment type: + +1. For issue/PR timeline comments (most common): + - GitHub issue comments do NOT support threaded replies - there is no reply endpoint. + - Create a new comment using: POST /repos/{owner}/{repo}/issues/{issue_number}/comments + - In your comment body, reference the triggering comment by quoting it or linking to it. + - Example: Start your comment with "> Replying to [comment](link):" or quote the relevant text. + +2. For PR review comments (inline code comments): + - These DO support threaded replies via the \`in_reply_to\` parameter. + - Use: POST /repos/{owner}/{repo}/pulls/{pull_number}/comments with \`in_reply_to\` set to the triggering comment ID. + +If no triggering comment ID is provided, simply create a new comment on the issue/PR. Your workflow: -1. Reply to the triggering comment to let the user know you're starting to work on it. - - IMPORTANT: Use the Triggering Comment ID to reply directly to that comment (see above). +1. Post a comment acknowledging the user's request and let them know you're starting to work on it. + - Reference the triggering comment (see instructions above for how to respond to comments). 2. Read the PR context and understand the request. 3. Create a Todo List: - - Update your reply comment with a todo list of what you're going to do. (Use the github-api tool to update your reply comment.) + - Update your comment with a todo list of what you're going to do. (Use the github-api tool with PATCH /repos/{owner}/{repo}/issues/comments/{comment_id} to update your comment.) - Use your GitHub comment to maintain a detailed task list based on the request. - Format todos as a checklist (- [ ] for incomplete, - [x] for complete). - Update the comment with each task completion. @@ -39,7 +49,7 @@ Your workflow: - Files modified - Links to PRs/commits 5. Final Comment Update (IMPORTANT): - - When you are completely done with all tasks, update your reply comment ONE FINAL TIME. + - When you are completely done with all tasks, update your comment ONE FINAL TIME. - REMOVE the entire task list/checklist from the comment. - Replace the comment body with ONLY a concise, minimal final summary. - Keep it brief: just state what was attempted and what was done.