Skip to content

Enhance secondary sessions with problem statement retrieval from Jobs API #7429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 28, 2025

This PR addresses an issue where secondary sessions (sessionIndex > 0) were not attempting to retrieve problem statements from request turn messages, unlike initial sessions which already had this functionality.

Problem

Previously, only the initial session (sessionIndex === 0) would try to fetch problem statements from the Jobs API using getJobBySessionId(). Secondary sessions would only look at timeline events (comments/reviews) for prompts, missing potentially valuable problem statement context that could improve the session's understanding of the user's intent.

Solution

Enhanced the getFollowUpSessionPrompt() method to mirror the problem statement retrieval logic from getInitialSessionPrompt():

  1. Added Jobs API call - Secondary sessions now first attempt to retrieve problem statements via capi.getJobBySessionId()
  2. Consistent title extraction - Uses the same TITLE regex pattern (/TITLE: \s*(.*)/i) to extract meaningful prompts from problem statements
  3. Graceful fallback - If no problem statement is found, the existing timeline event-based logic is preserved
  4. Enhanced logging - Added appropriate logging to track when problem statements are found for secondary sessions

Changes Made

  • Modified getFollowUpSessionPrompt() method signature to accept session, pullRequest, and capi parameters
  • Added problem statement retrieval logic at the beginning of the method
  • Updated the call in determineSessionPrompt() to pass the required parameters
  • Added comprehensive test coverage for the title extraction functionality

Backward Compatibility

This change is fully backward compatible. The existing timeline event-based fallback logic remains unchanged, ensuring that secondary sessions continue to work as before when no problem statement is available.

The enhancement follows the established pattern from initial session handling, maintaining code consistency and ensuring that all sessions now have equal access to problem statement context.

Created from VS Code via the GitHub Pull Request extension.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Enhancing Secondary Sessions with Problem Statement Retrieval Enhance secondary sessions with problem statement retrieval from Jobs API Jul 28, 2025
@Copilot Copilot AI requested a review from rebornix July 28, 2025 16:00
Copilot finished work on behalf of rebornix July 28, 2025 16:00
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.

2 participants