Skip to content

Conversation

@nstrayer
Copy link
Contributor

Addresses #10653.

This PR fixes an issue where the GitHub Copilot chat provider wasn't receiving notebook context in its system prompt when used with Positron Assistant. The Copilot provider now uses the same prompt construction path as the Anthropic provider, ensuring it receives complete notebook information (cells, outputs, variables) upfront rather than needing tool calls for basic context.

Additionally, this PR filters out Copilot's native notebook tools when Positron notebook mode is active to prevent conflicts with Positron's specialized notebook tools.

Release Notes

New Features

  • N/A

Bug Fixes

  • N/A

QA Notes

@:assistant @:notebooks

  1. Open a Jupyter notebook in Positron with some code cells
  2. Open Assistant and switch to Copilot chat provider
  3. Ask about the notebook (e.g., "What cells are in this notebook?" or "Summarize what this notebook does")

Expected:

  • Assistant should respond with knowledge of notebook cells without making tool calls
  • Behavior should match the Anthropic provider experience
  • Assistant should use Positron notebook tools (GetNotebookCells, EditNotebookCells, RunNotebookCells) not Copilot-native ones

@github-actions
Copy link

github-actions bot commented Nov 19, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:assistant @:notebooks

readme  valid tags

@nstrayer nstrayer requested a review from jmcphers November 19, 2025 15:16
Copilot finished reviewing on behalf of nstrayer November 19, 2025 15:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where the GitHub Copilot chat provider wasn't receiving notebook context in its system prompt when used with Positron Assistant. The changes ensure Copilot receives complete notebook information upfront (cells, outputs, variables) rather than needing tool calls, matching the behavior of the Anthropic provider. Additionally, Copilot's native notebook tools are filtered out when Positron notebook mode is active to prevent conflicts.

Key changes:

  • Added notebook context retrieval in generateAssistantPrompt to pass context to the prompt renderer
  • Added filtering logic to disable Copilot's native notebook tools when Positron notebook mode is active
  • Imported getAttachedNotebookContext and SerializedNotebookContext to support notebook context handling

Comment on lines 62 to 68
// Get notebook context if available, with error handling
let notebookContext: SerializedNotebookContext | undefined;
try {
notebookContext = await getAttachedNotebookContext(request);
} catch (err) {
log.error('[PositronAssistantApi] Error checking notebook context:', err);
}
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling added here for getAttachedNotebookContext is inconsistent with the Edit and Agent participant implementations in participants.ts (lines 791 and 813), which don't have try-catch blocks. Consider adding similar error handling to those implementations as well, or document why this API path needs different error handling than the participant paths.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@dhruvisompura dhruvisompura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried to test these changes locally and ran into some issues with getting a copilot chat provider to use the notebook tools 😭 . Not sure if there's a specific setting that I may be missing?

unrelated to this PR, but executing cells seems horribly borked which is making it hard to test the changes with cell outputs. Curious if you experienced this at all?

Here's what I am seeing on my end:

Screen.Recording.2025-11-20.at.3.42.49.PM.mov

Copy link
Contributor

@seeM seeM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too in the loop with Assistant changes so will let someone from the Assistant team review this one, once Dhruvi's issue has been addressed

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.

4 participants