Skip to content

feat: Add previous comments to issue context for better conversation awareness#4

Open
roger704 wants to merge 1 commit intocoleam00:mainfrom
roger704:feature/context-and-ux
Open

feat: Add previous comments to issue context for better conversation awareness#4
roger704 wants to merge 1 commit intocoleam00:mainfrom
roger704:feature/context-and-ux

Conversation

@roger704
Copy link

Summary

This PR improves conversation context by fetching previous comments and always including the issue description, not just on the first message.

Problem

On follow-up comments to an issue, the agent only received the new comment text with no context of:

  • The original issue description (only included for the first message)
  • Previous comments in the thread
  • What it had said or done before

This led to:

  • Repetitive responses (agent doesn't know what it already said)
  • Contradictory suggestions (forgets previous recommendations)
  • Loss of context in multi-turn conversations

Solution

1. Fetch Previous Comments

New fetchIssueComments() method retrieves up to 10 recent relevant comments:

const { data: comments } = await this.octokit.rest.issues.listComments({
  owner, repo, issue_number: issueNumber, per_page: 20
});

Bot acknowledgments are filtered out to keep context relevant.

2. Always Include Issue Context

Changed from:

if (isNewConversation) {
  finalMessage = this.buildIssueContext(issue, strippedComment);
}

To:

// Always include context, not just for new conversations
finalMessage = await this.buildIssueContext(owner, repo, issue, strippedComment);

3. Enhanced Context Format

The context now includes:

[GitHub Issue Context]
Issue #123: "Bug in login flow"
Author: user
Labels: bug
Status: open

Description:
<original issue body>

Previous Comments:
**user**: First comment...
**bot**: Response...
**user**: Follow-up...

---

<current user comment>

Benefits

  • Full conversation history - Agent sees what was discussed before
  • Continuity - Can continue work from where it left off
  • No repetition - Knows what it already said
  • Better follow-ups - Understands context of user's questions

Testing

Tested in production with multi-turn conversations - agent now correctly references previous discussion and avoids repetition.

…awareness

Problem:
On follow-up comments to an issue, the agent only received the new comment text.
It had no context of:
- The original issue description (only included for first message)
- Previous comments in the thread
- What it had said or done before

This led to repetitive or contradictory responses.

Solution:
1. **Fetch previous comments** via GitHub API (up to 10 recent relevant comments)
2. **Always include issue context** on every message, not just the first one
3. **Filter bot acknowledgments** to keep context relevant

Changes:
- Added `fetchIssueComments()` method to retrieve previous comments
- Modified `buildIssueContext()` to be async and include previous comments
- Changed context logic from `if (isNewConversation)` to always include

Benefits:
- Agent sees full conversation history
- Can continue work from where it left off
- Avoids repeating itself or contradicting previous responses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant