Skip to content

Add Copilot preference for a chat's custom instructions loading #62

Closed

Description

Updated to latest 0.14.0 Copilot today, Eclipse 4.38.
GitHub Copilot 0.14.0.202512112209 com.microsoft.copilot.eclipse.feature.feature.group GitHub Copilot

Chat view is unusable. Any request / prompt shows the error below, with different models in "Ask" mode on different files and with trivial questions like /explain or "what does this class?".

org.eclipse.lsp4e
Error
Fri Dec 12 09:21:45 CET 2025
[Error]	[chat] Error processing turn 861097da-6faf-43c8-9c8c-2b5eb97f9848 Error: maxTokens must be larger than the ellipsis length
    at t.elide (/snapshot/copilot-client/prompt/src/elidableText/elidableText.ts:118:19)
    at /snapshot/copilot-client/lib/src/conversation/prompt/conversationPromptEngine.ts:112:72
    at Array.map (<anonymous>)
    at q0.elideChatMessages (/snapshot/copilot-client/lib/src/conversation/prompt/conversationPromptEngine.ts:105:14)
    at q0.toPrompt (/snapshot/copilot-client/lib/src/conversation/prompt/conversationPromptEngine.ts:67:45)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at Zz.buildConversationPrompt (/snapshot/copilot-client/lib/src/conversation/turnProcessorStrategy.ts:79:16)
    at Bje.processWithModel (/snapshot/copilot-client/lib/src/conversation/turnProcessor.ts:189:36)
    at Bje.process (/snapshot/copilot-client/lib/src/conversation/turnProcessor.ts:90:13)
    at handleConversationCreateChecked (/snapshot/copilot-client/agent/src/methods/conversation/conversationCreate.ts:137:5)

It looks like the problem appears because we have few (~50) projects containing .github/copilot-instructions.md files in the workspace.

If I make the file empty, the problem disappears.

Note: the Chat view was asked on a fully unrelated file from a different project, on which the instructions of other projects shouldn't apply at all.

Update

It looks like there is a max limit of characters that could be used in .github/copilot-instructions.md file, multiplied by number of files in git repository.

With ~1700 characters for ~50 projects Chat view shows an error, with ~1300 it seem to work.

Reducing number of files also helps.

So the bug is:

Copilot plugin puts all found .github/copilot-instructions.md files from all projects into the context of the conversation in a Chat view, even if conversation scope is a file in a fully unrelated project (from the same git repository).

The first project below, with no instructions at all still seem to be affected by instructions from other projects

common git repo
--> Project/<no github instructions>
--> ProjectA/.github/copilot-instructions.md
--> ProjectB/.github/copilot-instructions.md
--> ProjectC/.github/copilot-instructions.md
--> ProjectD/.github/copilot-instructions.md
--> ProjectE/.github/copilot-instructions.md
--> ProjectF/.github/copilot-instructions.md

Activity

  1. iloveeclipse commented on Dec 12, 2025

    @iloveeclipse
    ContributorAuthor

    It looks like there is a max limit of characters that could be used in that file, multiplied by number of files.
    With ~1700 for ~50 projects it shows an error, with ~1300 it seem to work.

    Reducing number of files also helps.

    So the bug is:

    Copilot plugin puts all found .github/copilot-instructions.md files from all projects into the context of the conversation in a Chat view, even if conversation scope is a file in a fully unrelated project (from the same git repository).

    The first project below, with no instructions at all still seem to be affected by instructions from other projects

    common git repo
    --> Project/<no github instructions>
    --> ProjectA/.github/copilot-instructions.md
    --> ProjectB/.github/copilot-instructions.md
    --> ProjectC/.github/copilot-instructions.md
    --> ProjectD/.github/copilot-instructions.md
    --> ProjectE/.github/copilot-instructions.md
    --> ProjectF/.github/copilot-instructions.md
    
  2. iloveeclipse commented on Dec 12, 2025

    @iloveeclipse
    ContributorAuthor

    Actually I've noticed this problem exists also in 0.13.1 version, the reason I see it now is that I've got the updated .github/copilot-instructions.md file with more content on my branch.

    So it is not a regression in 0.14.0 but just a bug :-(

  3. jdneo commented on Dec 15, 2025

    @jdneo
    Member

    Basically the content of those instructions will be put as part of the context for the model. And because each model will have max token limitation, if the context is too big (bigger than the max token limitation), it breaks.

    I saw there are two bugs actually in this ticket.

    1. In CLS, it does not handle the exceed of the token gracefully. We should try to cut the content instead of throwing an error.
    2. In the client side, the instruction handling needs to be improved. So far I have no idea how to smartly pick the 'relevant' instruction files. So maybe change the setting to a file picker, that allow user to pick the required on demand.
  4. iloveeclipse commented on Dec 15, 2025

    @iloveeclipse
    ContributorAuthor

    2. So far I have no idea how to smartly pick the 'relevant' instruction files. So maybe change the setting to a file picker, that allow user to pick the required on demand.

    In Eclipse model, files are grouped by projects, projects may have specific settings, and there are workspace settings if nothing is defined in a project (user can also open "external" files, not located in any project, but this is the corner case, so let skip this for now).

    Additionally to that, we have git (and other version control systems) where some projects might be physically located and may want to share common "repository" settings (even if these settings are located outside of any Eclipse project).

    So let assume we have a Chat view opened with a single file context (simple case).

    What would we need to provide right instructions file (efficiently, assuming we have to deal with workspaces of unlimited size, so like ~1.000 projects or 500.000 files)?

    For a given path in the workspace the algorithm would need to check

    1. Get a project for given file.
    2. If no project exists, use workspace instructions file (if there is one)
    3. If there is a project, check <project>.github/.copilot-instructions.md file. If it exists, use this file.
    4. If there is no project instructions file, check if project is contained in a VCS - go up to the file system root for known VCS markers like .git directory etc).
    5. If there is no VCS found for project, use workspace instructions file (if there is one)

    To avoid heavy IO (searching VCS root every time), let have a simple cached data structure, name it InstrutionsLookup and keep there map of "Project root path -> VCS root path", also one could cache there last lookup results.

    Now one can have multiple files in the context, so additionally the algorithm would need to do following:

    1. For each file find related instructions file according to algorithm above, so we have a map "file in context -> instructions file".
    2. In this map, try to reduce values set to a single element. If this doesn't work, no common instructions file can be used.
    3. To reduce the set, note, that instruction files can be linked, both internally by Eclipse of by means of underlined files system links. So traverse the set and resolve each instructions file to a "real" location on file system. As soon as we found first not matching file, we are done, no common instructions file can be used, otherwise, at the end we have a single instructions file, that is what we can use for given context.
    4. If there is no common instructions file found, one could either ask user to select one from found files or decide if workspace instructions should be used etc.
  5. jdneo commented on Dec 15, 2025

    @jdneo
    Member

    Yes for sure we can resolve all the 'relevant' instruction files according to the attached context files.

    What about user does not attach any context file and expects LLM to figure it out by itself? Especially when we have semantic search tool and more and more powerful models nowadays.

    Recently when I use copilot, in most cases I will not attach any context file and usually the LLM can handle the case gracefully.

  6. iloveeclipse commented on Dec 15, 2025

    @iloveeclipse
    ContributorAuthor

    What about user does not attach any context file and expects LLM to figure it out by itself?

    Workspace instructions file (if any), or dialog asking to create one / select one from the list to be the "default" workspace instructions file. Also you could specify whether workspace instructions should be overridden by project specific instructions or should be added to the project instructions, both can make sense.

    But for now, if the Chat view doesn't have a context file linked, it can't and should not use some instructions file from "automatically" found instructions files set.

    If there is only one file found in the workspace, you may think this is correct one, but this is wrong.

    1. Let assume user will clone a "cool" repository with some code & malicious instructions file inside, import a project from it into the workspace, next to existing project with "regular" data. Now if this malicious instructions file would be the only found instructions file in the workspace, it could instruct the model to do something really bad, and user will not even know about that!
    2. It doesn't need to be a security issue. Let assume, we have few projects with low level C++ code, few projects with high level Java code and few web projects with javascript, html and and css files. Each of the "layers" might have its own instructions file, like C++ cares about specific memory usage patterns, Java about specific logging library instructions and web project a policies about some modern js framework to use. Using C++ instructions for questions related to web project would not make any sense, and vice versa.
  7. jdneo commented on Jan 9, 2026

    @jdneo
    Member

    Currently the workaround is to close irrelevant projects in workspace. I've thought about introducing a dialog to allow user to configure the 'working projects', but get paused since it's actually similar to closing/opening projects.

    Still thinking about the solution...

  8. iloveeclipse commented on Jan 9, 2026

    @iloveeclipse
    ContributorAuthor

    Currently the workaround is to close irrelevant projects in workspace.

    Not possible. We have ~300 interdependent projects. Closing some / most will create lot of compilation errors.

    I've thought about introducing a dialog to allow user to configure the 'working projects'

    If there are no files, let ask user & set it as a "prefferred workspace instructions file", but for the rest just find what is directly related as proposed above.

  9. jdneo commented on Jan 9, 2026

    @jdneo
    Member

    Only pick the instruction from the project where the context belongs to is fine in most cases. But what if:

    The user's prompts results in the LLM to modify the project of the context and its interdependent projects?

  10. iloveeclipse commented on Jan 9, 2026

    @iloveeclipse
    ContributorAuthor

    I assume Copilot UI will not parse the prompt, so it has to add instructuctions to agents before LLM realizes the "other" projects are affected. I would assume adding workspace level instructions could be fine in that case.

    Another possibility is to check upfront how much "known" instruction files exists and if there are not too many / too big, use them all, but as I've mentioned earlier, it would make no sense in hybrid environments, where fully different projects from fully different repositories are existing. One says "don't touch C++ code, it is generated JNI stubs", the other says exact the opposite "don't touch Java code, it's generated from IDL files".

    So honestly, by default, I would only use instructions from the context projects & workspace level.

    Maybe another possibility would be that if user finds out, there are "other" projects involved (not directly in the context), offer the possibility to configure that in the Chat view, similar to files, add projects to the context.

  11. changed the title [-]Chat view doesn't work, reports "Error: maxTokens must be larger than the ellipsis length"[/-] [+]Copilot instructions affect unrelated projects, Chat view doesn't work, reports "Error: maxTokens must be larger than the ellipsis length"[/+] on Apr 29, 2026
  12. iloveeclipse commented on Apr 29, 2026

    @iloveeclipse
    ContributorAuthor

    OK, discussed this shortly in person.

    For most files in Eclipse which can be referenced in the Chat view, a project is given. If this project has .github/copilot-instructions.md file, agent can "know" the right instructions automatically.

    The main point to solve now is: "what if agent need to modify other files from different projects", how we can give him right instructions there (assuming they differ from originally referenced project).

    The proposal: let add some kind of "instructions picker" widget in the Chat view, which would allow user to select other instruction files found in the workspace. It could be "kind of" combo box with checkboxes inside or simply a button which would open a dialog showing all found unique instruction files found in the workspace.

    By default, the Chat view and picker would have selected the instruction files from all the projects of the files added to the Chat context, and show all other found instruction files as not selected.

    WDYT?

  13. jdneo commented on Apr 29, 2026

    @jdneo
    Member

    Will it make sense if we introduce this preference page like in VS Code?

    Image
  14. iloveeclipse commented on Apr 29, 2026

    @iloveeclipse
    ContributorAuthor

    Will it make sense if we introduce this preference page like in VS Code?

    This alone may not solve our problem with ~200+ projects in the workspace, each having some instructions.md file.

    Right now we have ~3 different instructions.md files "per software layer". Every project from a specific layer links to one of htese files. There are also specific instructions.md files for test projects, UI / headless project etc.

    So in such preference page one would see ~200+ instruction files. Not sure the table alone would be helpful, but yes, at least one could exclude most of the files from the list, whch would be a workaround for us.

    Since most of the files are links, let assume the preference page will sort it out and show only 10 real files.

    With those ~10 "real" files, each 10K big (approx ~2500 words) we will pass 100K to LS on every conversation. It may work physically for now (and stop working tomorrow if people add more content to their files), but even now with 10+ files agent will see fully different, partly contradicting instructions for the file in Chat context. It will see instructions for Eclipse Java plugins code that works with UI, headless Java code running in fully different context, C++ code for HW drivers, shell code talking via ruby or python with some Linux programs... Double that chaos by separated instructions for test projects and production projects... Not sure it would make sense from AI answers quality point of view and if it will scale in long term.

    But let assume we will provide preference page for every file found in the workspace, what about adding a checkbox or radio boxes above the table with found instruction files like:

    "For the conversations in the Chat view:"

    • "Always use all enabled instruction files"
    • "Only use enabled instructions from project in context"

    For us, with our 200+ instruction files, we would simply set the second preference by default and everyone will be happy.

    WDYT?

  15. jdneo commented on Apr 29, 2026

    @jdneo
    Member

    Ah, I checked the implementation of CLS side, and found that the way how instruction files are discivered

    1. Basically, we need to pass workspace folders to CLS for each chat:
    2. CLS will search .github/copilot-instructions.md per workspace folders.

    So seems that instead of limit the .md files discovery, we should limit the workspace folders. (That's way previously we have explored about working project concept)

  16. iloveeclipse commented on Apr 29, 2026

    @iloveeclipse
    ContributorAuthor

    So seems that instead of limit the .md files discovery, we should limit the workspace folders.

    Correct. I see org.eclipse.lsp4e.LSPEclipseUtils.getWorkspaceFolders() returns all projects in the workspace unconditionally. Ideally this should be just the projects for all files referenced in the Chat vew.

    Again, if the agent will need to know about other projects, we might use preference page to check which instruction files are "enabled" and additionally put their projects to the list of "WorkspaceFolders".

  17. jdneo commented on Apr 29, 2026

    @jdneo
    Member

    So there will be a new preference, enum type, indicating how the workspace folders (projects) pass to CLS, candidate values are:

    • All projects
    • Referenced projects inferred via attached files/folders
  18. travkin79 commented on Apr 29, 2026

    @travkin79
    Contributor

    I've read all your posts here. I would like to elaborate a solution, but I doubt that we have the same expectations and understanding. So let's try to summarize and clarify a few things.

    If I don't misunderstand you, the major issues with the current state are

    • too many loaded custom instructions (for all projects from workspace) which leads to
      • thrown exceptions due to various limits
      • potentially contradicting instructions or polluted context (unintended agent behavior)
      • unnecessarily loaded instructions (unintended token consumption)

    That leads to the main question: What are the relevant custom instructions for a set of files in the context (selected in the chat view) and the current workspace?

    AFAIK we need to respect the following concepts / conventions:

    • custom instructions per Eclipse project (<project>/.github/copilot-instructions.md) -- I'd say, they should always apply if files will be read / modified in that project
    • custom instructions per Eclipse workspace (Eclipse preferences) -- Workspace settings usually apply if there are no such project-specific settings
    • custom instructions in git repository root directory (<repo root dir>/.github/copilot-instructions.md) -- I'd say, they should always be applied if files will be read / modified in that git repo
    • custom instructions in the user's home directory (~/.copilot/copilot-instructions.md) -- I'd say, these should always be applied if available
    • Maybe new concepts of adding custom instructions explicitly via chat view or copilot for Eclipse preferences

    If we focus on files explicitly added to the context, I would suggest the following process of adding custom instructions.

    Image

    Sheng Chen (@jdneo) and Andrey Loskutov (@iloveeclipse), do you agree with that part?

    The steps above don't handle the following case:

    But what if: The user's prompts results in the LLM to modify the project of the context and its interdependent projects?

    In order to handle that case, too, I though of a kind of scope analysis step to automatically find additional projects involved in the requested agent task? Is that possible? If that is somehow possible, we could append the following steps to the previous process to add the custom instructions from these additional projects and their git repos.

    Image

    In addition, I didn't cover symbolic links pointing to effectively same instruction files.

    Sheng Chen (@jdneo) suggested the following.

    So there will be a new preference, enum type, indicating how the workspace folders (projects) pass to CLS, candidate values are:

    All projects
    Referenced projects inferred via attached files/folders

    Picking up Andrey Loskutov (@iloveeclipse)'s arguments, I doubt that loading custom instructions from all projects in the workspace is a good idea in any case. I suggest to always load only relevant custom instructions.

  19. jdneo commented on Apr 30, 2026

    @jdneo
    Member

    Picking up Andrey Loskutov (@iloveeclipse)'s arguments, I doubt that loading custom instructions from all projects in the workspace is a good idea in any case. I suggest to always load only relevant custom instructions.

    One more comment from my side:

    When you are using a powerful model, it can find all related files via different search approaches. This makes it less likely that context files needs to be manually attached. Thus, inferring the related projects based on attached files won't be always reliable.

    I think maybe(?) the right approach to support your case is to support to *.instructions.md, see: https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/add-custom-instructions/add-repository-instructions#creating-path-specific-custom-instructions

    That means, you put all the needed instruction files to a single place - the root of your git folder (/.github/instructions/*.md). Then we have a picker or table to let user enable/disable the instructions

    Image

    Andrey Loskutov (@iloveeclipse) said there are around 10 unique instructions, I think it is acceptable to render ~10 entries in a table or picker?

  20. travkin79 commented on Apr 30, 2026

    @travkin79
    Contributor

    Hi Sheng Chen (@jdneo),

    When you are using a powerful model, it can find all related files via different search approaches. This makes it less likely that context files needs to be manually attached.

    I agree with that. From a user's point of view, I'd wish that the LLM / IDE automatically picks up the relevant files and also the relevant custom instructions, without having to configure anything (if possible). Assuming the LLM can find related files itself, we could maybe also assume, the LLM can pick up related custom instructions itself, too. I'd conclude that (for now) we don't need to explicitly load custom instructions from potentially related projects, i.e. for files / projects that are not in the context (that should likely be decided by the LLM).

    But I think for files that are part of the context (or part of the agent's "working directory"), we should explicitly and deterministicly load custom instructions. For this case, the control flow from my first diagram could by a solution. That would mean that in general, we would no longer load custom instructions from all projects, but would load only relevant ones. Then we need to agree on what "relevant" means. What do you think, Sheng Chen (@jdneo) and Andrey Loskutov (@iloveeclipse)?

    I think maybe(?) the right approach to support your case is to support to *.instructions.md, see: https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/add-custom-instructions/add-repository-instructions#creating-path-specific-custom-instructions

    That means, you put all the needed instruction files to a single place - the root of your git folder (/.github/instructions/*.md). Then we have a picker or table to let user enable/disable the instructions

    That's a really interesting idea and might solve the case described by Andrey Loskutov (@iloveeclipse). That could complement what I suggested above. If I understand the docs correctly, the custom instructions could be automatically picked up using glob patterns in an instruction file's front matter block e.g. applyTo: "app/models/**/*.rb". Do we then still need to actively choose the instruction files to be used in a session (or in general)? According to the docs, the instruction files can be de-activated for the code-review agent (if needed), but that could also be done in the front matter block of an instructions file.

    Concerning the instruction files selection dialog from VSCode, it looks to me as if its main purpose is to re-use the custom instructions from Claude and other AI tools. Maybe it would be helpful if users could decide, whether they want to include these additional (non-Copilot) instructions or not, by using an Eclipse preferences page. (Besides, it seems, the VSCode dialog does not cover all conventions for custom instructions, e.g. copilot-instructions.md and AGENTS.md (used by Copilot CLI) don't match the file pattern *.instructions.md from the dialog.)

  21. iloveeclipse commented on Apr 30, 2026

    @iloveeclipse
    ContributorAuthor

    That means, you put all the needed instruction files to a single place - the root of your git folder (/.github/instructions/*.md). Then we have a picker or table to let user enable/disable the instructions

    Unfortunately this isn't applicable for our use case.

    We enforce "standard" project settings, files etc in each project. We have lot of projects, so to avoid code duplication, if project code owners don't need extra settings, they simply link to the default templates. This is what I meant that we might have not 200 but just 10 "real" files, others are just links.

    So every project has its own settings files linked to templates or can have custom.

    Putting every project specific files to the root of the git repo would make no sense, as it would cause extra overhead maintaining projects <-> settings for every project.

    But I think for files that are part of the context (or part of the agent's "working directory"), we should explicitly and deterministicly load custom instructions. For this case, the control flow from my first diagram could by a solution. That would mean that in general, we would no longer load custom instructions from all projects, but would load only relevant ones. Then we need to agree on what "relevant" means.

    We are going in rounds here. Relevant projects are those matching the files added to the context, but again, if agent would need to touch files outside the context, it may want to need instructions from additional projects.

    Can we for now simply implement preference proposed in this comment?

    This is most simple solution, which will immediately help. All extra enhancements can follow up.

  22. jdneo commented on Apr 30, 2026

    @jdneo
    Member

    Can we for now simply implement preference proposed #62 (comment)?

    Yes, that is the most direct and fast approach.

    I think I also need to check the cls implementation if it already dedup the instructions that link to the same original file.

    Andrey Loskutov (@iloveeclipse) How are those files linked? symbol link?

  23. iloveeclipse commented on Apr 30, 2026

    @iloveeclipse
    ContributorAuthor

    How are those files linked? symbol link?

    Yes

  24. travkin79 commented on Apr 30, 2026

    @travkin79
    Contributor

    Can we for now simply implement preference proposed #62 (comment)?

    Ok, I could try implementing a PR for that.

  25. changed the title [-]Copilot instructions affect unrelated projects, Chat view doesn't work, reports "Error: maxTokens must be larger than the ellipsis length"[/-] [+]Add Copilot preference for a chat's custom instructions loading[/+] on May 15, 2026
  26. iloveeclipse commented on May 20, 2026

    @iloveeclipse
    ContributorAuthor

    This ticket should be fixed now in 0.18 via #136.
    Thanks everyone involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions