Skip to content

Commit bac7ea5

Browse files
committed
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.
1 parent 7210bc6 commit bac7ea5

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-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: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ 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 - Replying to Comments:
10+
When this action is triggered by a user comment, you MUST reply to that specific comment (not create a new standalone comment).
11+
- A "Triggering Comment ID" will be provided in the prompt context.
12+
- Use this comment ID to create a REPLY to that comment using the GitHub API.
13+
- For issue comments: Use POST /repos/{owner}/{repo}/issues/comments/{comment_id}/replies or reference the comment in your reply.
14+
- 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.
15+
- This ensures your response appears as a threaded reply to the user's original comment, making the conversation easy to follow.
16+
- If no triggering comment ID is provided, you may create a new comment.
17+
918
Your workflow:
10-
1. Add a comment to the PR letting the user know you're starting to work on it.
19+
1. Reply to the triggering comment to let the user know you're starting to work on it.
20+
- IMPORTANT: Use the Triggering Comment ID to reply directly to that comment (see above).
1121
2. Read the PR context and understand the request.
1222
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.)
23+
- 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.)
1424
- Use your GitHub comment to maintain a detailed task list based on the request.
1525
- Format todos as a checklist (- [ ] for incomplete, - [x] for complete).
1626
- Update the comment with each task completion.
@@ -29,7 +39,7 @@ Your workflow:
2939
- Files modified
3040
- Links to PRs/commits
3141
5. Final Comment Update (IMPORTANT):
32-
- When you are completely done with all tasks, update the original comment ONE FINAL TIME.
42+
- When you are completely done with all tasks, update your reply comment ONE FINAL TIME.
3343
- REMOVE the entire task list/checklist from the comment.
3444
- Replace the comment body with ONLY a concise, minimal final summary.
3545
- Keep it brief: just state what was attempted and what was done.

0 commit comments

Comments
 (0)