Skip to content

Commit a2c41eb

Browse files
authored
Merge pull request #2 from augmentcode/fix/ensure-reply-to-triggering-comment
Fix: Ensure agent responses are replies to the triggering comment
2 parents 7210bc6 + 2e2096c commit a2c41eb

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

src/auggie.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export type RunAuggieOptions = {
1414
context?: GithubPullRequest;
1515
/** The body of the comment that triggered this action, if triggered by a comment */
1616
commentBody?: string;
17+
/** The ID of the comment that triggered this action, if triggered by a comment */
18+
commentId?: number;
1719
};
1820

1921
/**
@@ -27,6 +29,7 @@ export async function runAuggie(options: RunAuggieOptions): Promise<string> {
2729
workspaceRoot,
2830
context,
2931
commentBody,
32+
commentId,
3033
} = options;
3134

3235
const workspace = workspaceRoot || process.cwd();
@@ -70,6 +73,12 @@ export async function runAuggie(options: RunAuggieOptions): Promise<string> {
7073
core.info("📨 User comment included in prompt");
7174
}
7275

76+
// Add triggering comment ID if available
77+
if (commentId) {
78+
fullPrompt = `${fullPrompt}\n\n## Triggering Comment ID:\n${commentId}`;
79+
core.info(`📍 Triggering comment ID: ${commentId}`);
80+
}
81+
7382
// Add user prompt
7483
fullPrompt = `${fullPrompt}\n\n${userPrompt}`;
7584

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ async function main(): Promise<void> {
1919
augmentApiUrl,
2020
workspaceRoot,
2121
commentBody,
22+
commentId,
2223
} = getAuggieParams();
2324
const { owner, repo } = parseRepository();
2425
const githubToken = process.env.GITHUB_TOKEN;
@@ -34,6 +35,7 @@ async function main(): Promise<void> {
3435
apiUrl: augmentApiUrl,
3536
workspaceRoot: workspaceRoot || undefined,
3637
commentBody,
38+
commentId,
3739
});
3840

3941
core.info("✅ Auggie agent completed successfully");

src/utils/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ type AuggieParams = {
169169
augmentApiUrl: string;
170170
workspaceRoot: string | undefined;
171171
commentBody: string | undefined;
172+
commentId: number | undefined;
172173
};
173174

174175
/**
@@ -189,12 +190,14 @@ export function getAuggieParams(): AuggieParams {
189190
const augmentApiUrl = getInput("augment_api_url", true);
190191
const workspaceRoot = getInput("workspace_root");
191192
const commentBody = getCommentBodyFromEvent();
193+
const commentId = getCommentIdFromEvent();
192194
return {
193195
eventName,
194196
prompt,
195197
augmentApiKey,
196198
augmentApiUrl,
197199
workspaceRoot,
198200
commentBody,
201+
commentId,
199202
}
200203
}

src/utils/prompt.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,31 @@ Important: How you handle changes depends on the context:
66
- If you are working on a Pull Request (PR): You are allowed to commit directly to that PR's branch.
77
- If you are working on a GitHub Issue: You must create a new branch and open a Pull Request with your changes.
88
9+
CRITICAL - Responding to Comments:
10+
When this action is triggered by a user comment, you should acknowledge the triggering comment in your response.
11+
- A "Triggering Comment ID" will be provided in the prompt context.
12+
- Use the github-api tool to interact with GitHub.
13+
14+
How to respond depends on the comment type:
15+
16+
1. For issue/PR timeline comments (most common):
17+
- GitHub issue comments do NOT support threaded replies - there is no reply endpoint.
18+
- Create a new comment using: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
19+
- In your comment body, reference the triggering comment by quoting it or linking to it.
20+
- Example: Start your comment with "> Replying to [comment](link):" or quote the relevant text.
21+
22+
2. For PR review comments (inline code comments):
23+
- These DO support threaded replies via the \`in_reply_to\` parameter.
24+
- Use: POST /repos/{owner}/{repo}/pulls/{pull_number}/comments with \`in_reply_to\` set to the triggering comment ID.
25+
26+
If no triggering comment ID is provided, simply create a new comment on the issue/PR.
27+
928
Your workflow:
10-
1. Add a comment to the PR letting the user know you're starting to work on it.
29+
1. Post a comment acknowledging the user's request and let them know you're starting to work on it.
30+
- Reference the triggering comment (see instructions above for how to respond to comments).
1131
2. Read the PR context and understand the request.
1232
3. Create a Todo List:
13-
- 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.)
33+
- 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.)
1434
- Use your GitHub comment to maintain a detailed task list based on the request.
1535
- Format todos as a checklist (- [ ] for incomplete, - [x] for complete).
1636
- Update the comment with each task completion.
@@ -29,7 +49,7 @@ Your workflow:
2949
- Files modified
3050
- Links to PRs/commits
3151
5. Final Comment Update (IMPORTANT):
32-
- When you are completely done with all tasks, update the original comment ONE FINAL TIME.
52+
- When you are completely done with all tasks, update your comment ONE FINAL TIME.
3353
- REMOVE the entire task list/checklist from the comment.
3454
- Replace the comment body with ONLY a concise, minimal final summary.
3555
- Keep it brief: just state what was attempted and what was done.

0 commit comments

Comments
 (0)