Closed vkz closed 5 months ago
What do you mean by other project files?
Events (open, focus, didChange, etc.) are only sent for buffers where copilot-mode
is active (unless global-copilot-mode
is active of course).
Here's an example:
/foo/.git
/foo/a.py
/foo/b.py
/foo/c.py
I'm actively working on c.py
. I also have buffers visiting a.py
and b.py
open. All have copilot enabled. When I trigger copilot in c.py
, will Github LLM receive additional context from a.py
and b.py
? In VSCode I'm pretty confident the answer is YES (well, it is a bit more complicated, what with the heuristics they apply, but kinda YES). In Emacs, however, I strongly suspect the answer is NO.
It works a bit differently in copilot.el
. Context is sent to the agent as you open, modify, switch to buffers, etc. not when you request a completion.
The flow would look something like this (simplified):
didOpen
event with the entire contents of the buffer of a.py
(up to a maximum amount of copilot-max-char
characters).didOpen
event with the entire contents of the buffer of b.py
(up to a maximum amount of copilot-max-char
characters).didOpen
event with the entire contents of the buffer of c.py
(up to a maximum amount of copilot-max-char
characters).a.py
again
copilot sends a didFocus
event for buffer a.py
a.py
copilot sends a didChange
event for buffer a.py
c.py
copilot sends a didFocus
event for buffer c.py
c.py
copilot requests a completion at the specific point in the documentThe same goes for any other buffer you open, switch to, modify when copilot mode is locally active in that buffer.
All that being said, copilot.el
sends events to keep the state of the agent up to date and does not send state when requesting a completion.
This explains the events - very helpful. Without my knowing what those events translate to in the copilot on the server, though, I can't answer the original and main question: when I work on c.py
will a.py
and b.py
be part of the context for completions in c.py
? With VSCode the answer is a definitiev YES (with caveats re context window, number of open files and their proprietary heuristics - i.e. maybe only parts of those files will make up the context available to LLM). Think you could shed some light there? That'll be very helpful. Thank you
I am quite certain that, yes, the agent should use the recent context (more than just the most recently focused buffer) for completions. The behaviour should be no different than copilot.vim in that respect.
I.e. it should take into account the content of buffers a.py
and b.py
when creating completions in buffer c.py
given the scenario you outlined above.
Thank you for your answer! This is very good to know. Hope it saves others some head scratching.
Closing
Could anyone give a definitive answer here, please? A few closed issues I've seen seem to suggest, the answer is no, and in fact only part of the active buffer is being sent as context. But having looked through the code we appear to send a few notifications to whenever file changes or file is open, etc.
Would be very helpful to know how far apart VSC copilot and Emacs.
Thank you