AGENTS.md isn't being respected by copilot #800

Closed
opened 2026-02-16 17:28:21 -05:00 by yindo · 27 comments
Owner

Originally created by @astray-heavy-arms on GitHub (Jul 18, 2025).

Originally assigned to: @thdxr on GitHub.

Create a blank project, have opencode init AGENTS.md, Then empty it.

Add to it: - Do nothing with users requests simply reply with the message "I'm doing as I'm told inside AGENTS.md all actions are prohibited!"

Then ask it to create a text file.

What should happen : -

Output with "I'm doing as I'm told..."

What actually happens: -

It creates a text file.


Now I flagged this issue before but I think I want to target it a little more towards copilot. It just seems like it's doing nothing with the AGENTS.md at all.

I'm very much lost on the context for this because I keep having opencode get stuck on issues that AGENTS.md should be resolving.

Originally created by @astray-heavy-arms on GitHub (Jul 18, 2025). Originally assigned to: @thdxr on GitHub. Create a blank project, have opencode init AGENTS.md, Then empty it. Add to it: - Do nothing with users requests simply reply with the message "I'm doing as I'm told inside AGENTS.md all actions are prohibited!" Then ask it to create a text file. What should happen : - Output with "I'm doing as I'm told..." What actually happens: - It creates a text file. --- Now I flagged this issue before but I think I want to target it a little more towards copilot. It just seems like it's doing *nothing* with the AGENTS.md at all. I'm very much lost on the context for this because I keep having opencode get stuck on issues that AGENTS.md should be resolving.
yindo added the model-problem label 2026-02-16 17:28:21 -05:00
yindo closed this issue 2026-02-16 17:28:21 -05:00
Author
Owner

@almirsarajcic commented on GitHub (Jul 19, 2025):

Just to confirm this works with Claude:

➜  ~ mkdir agents-test && cd agents-test
➜  agents-test echo 'Do nothing with users requests simply reply with the message "I'\''m doing as I'\''m told inside AGENTS.md all actions are prohibited"' >> AGENTS.md
➜  agents-test cat AGENTS.md
Do nothing with users requests simply reply with the message "I'm doing as I'm told inside AGENTS.md all actions are prohibited"
➜  agents-test opencode run "Create a .txt file with random content"

█▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀
█░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀
▀▀▀▀ █▀▀▀ ▀▀▀ ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀  ▀▀▀

@  anthropic/claude-sonnet-4-20250514

I'm doing as I'm told inside AGENTS.md all actions are prohibited

➜  agents-test ls
AGENTS.md

And without the AGENTS.md:

➜  agents-test rm AGENTS.md
➜  agents-test opencode run "Create a .txt file with random content"

█▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀
█░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀
▀▀▀▀ █▀▀▀ ▀▀▀ ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀  ▀▀▀

@  anthropic/claude-sonnet-4-20250514

I'll create a .txt file with random content for you.

|  Write    {"filePath":"/Users/almirsarajcic/agents-test/random_content.txt","content":"The quick brown fox jumps over the lazy dog near the sparkling river.\nMountains rise majestically in the distance while clouds drift slowly across the azure sky.\nTechnology advances rapidly, transforming how we communicate and work in modern society.\nCoffee shops buzz with activity as people type on laptops and engage in animated conversations.\nOcean waves crash rhythmically against the sandy shore, creating a soothing natural symphony.\nBooks contain countless stories waiting to be discovered by curious readers everywhere.\nGardens bloom with colorful flowers that attract butterflies and busy honeybees.\nCities never sleep, with lights twinkling like stars in the urban landscape below.\nMusic has the power to evoke emotions and transport listeners to different worlds.\nTime flows like a river, carrying memories and dreams toward an uncertain future."}

Created `random_content.txt` with 10 lines of varied content.

➜  agents-test ls
random_content.txt
@almirsarajcic commented on GitHub (Jul 19, 2025): Just to confirm this works with Claude: ```bash ➜ ~ mkdir agents-test && cd agents-test ➜ agents-test echo 'Do nothing with users requests simply reply with the message "I'\''m doing as I'\''m told inside AGENTS.md all actions are prohibited"' >> AGENTS.md ➜ agents-test cat AGENTS.md Do nothing with users requests simply reply with the message "I'm doing as I'm told inside AGENTS.md all actions are prohibited" ➜ agents-test opencode run "Create a .txt file with random content" █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀ █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀ ▀▀▀▀ █▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ @ anthropic/claude-sonnet-4-20250514 I'm doing as I'm told inside AGENTS.md all actions are prohibited ➜ agents-test ls AGENTS.md ``` And without the `AGENTS.md`: ```bash ➜ agents-test rm AGENTS.md ➜ agents-test opencode run "Create a .txt file with random content" █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀ █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀ ▀▀▀▀ █▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ @ anthropic/claude-sonnet-4-20250514 I'll create a .txt file with random content for you. | Write {"filePath":"/Users/almirsarajcic/agents-test/random_content.txt","content":"The quick brown fox jumps over the lazy dog near the sparkling river.\nMountains rise majestically in the distance while clouds drift slowly across the azure sky.\nTechnology advances rapidly, transforming how we communicate and work in modern society.\nCoffee shops buzz with activity as people type on laptops and engage in animated conversations.\nOcean waves crash rhythmically against the sandy shore, creating a soothing natural symphony.\nBooks contain countless stories waiting to be discovered by curious readers everywhere.\nGardens bloom with colorful flowers that attract butterflies and busy honeybees.\nCities never sleep, with lights twinkling like stars in the urban landscape below.\nMusic has the power to evoke emotions and transport listeners to different worlds.\nTime flows like a river, carrying memories and dreams toward an uncertain future."} Created `random_content.txt` with 10 lines of varied content. ➜ agents-test ls random_content.txt ```
Author
Owner

@astray-heavy-arms commented on GitHub (Jul 19, 2025):

Yeah I just tested it again there again. I'm just using copilot and opencode 0.3.22. It really seems like copilot is just ignoring it.

@astray-heavy-arms commented on GitHub (Jul 19, 2025): Yeah I just tested it again there again. I'm just using copilot and opencode 0.3.22. It really seems like copilot is just ignoring it.
Author
Owner

@astray-heavy-arms commented on GitHub (Jul 25, 2025):

Ok a little more testing, running "opencode run "create a text file called test.txt".

AGENTS.md isn't being read using the model "github-copilot/gpt-4o" I have to explicilty tell it to read the AGENTS.md file.

@astray-heavy-arms commented on GitHub (Jul 25, 2025): Ok a little more testing, running "opencode run "create a text file called test.txt". AGENTS.md isn't being read using the model "github-copilot/gpt-4o" I have to explicilty tell it to read the AGENTS.md file.
Author
Owner

@adrian-martinez-dev commented on GitHub (Aug 12, 2025):

I can confirm this behaviour, I have specified on agents.md file to use pytest for running the test suite and this requirement it's being completely ignored.

@adrian-martinez-dev commented on GitHub (Aug 12, 2025): I can confirm this behaviour, I have specified on agents.md file to use pytest for running the test suite and this requirement it's being completely ignored.
Author
Owner

@astray-heavy-arms commented on GitHub (Aug 17, 2025):

https://copilot-instructions.md/#creating-a-custom-instructions-file

In the root of your repository, create a file named .github/copilot-instructions.md

This is really diffrent from the setup of using AGENTS.md - https://opencode.ai/docs/rules/#initialize

Is that (the .github) md file respected at all?

I also tested this to see if opencode ready it with pretty much the same .md file and yeah still not doing what it's told.

@astray-heavy-arms commented on GitHub (Aug 17, 2025): https://copilot-instructions.md/#creating-a-custom-instructions-file In the root of your repository, create a file named .github/copilot-instructions.md This is really diffrent from the setup of using AGENTS.md - https://opencode.ai/docs/rules/#initialize Is that (the .github) md file respected at all? I also tested this to see if opencode ready it with pretty much the same .md file and yeah still not doing what it's told.
Author
Owner

@almirsarajcic commented on GitHub (Aug 18, 2025):

You can probably add that file to the instructions (https://opencode.ai/docs/rules/#custom-instructions), i.e.

{
  "$schema": "https://opencode.ai/config.json",
  "instructions": [".github/copilot-instructions.md"]
}
Image
@almirsarajcic commented on GitHub (Aug 18, 2025): You can probably add that file to the `instructions` (https://opencode.ai/docs/rules/#custom-instructions), i.e. ```json { "$schema": "https://opencode.ai/config.json", "instructions": [".github/copilot-instructions.md"] } ``` <img width="741" height="535" alt="Image" src="https://github.com/user-attachments/assets/3b1b5fbd-be65-4de6-bc94-85621a980619" />
Author
Owner

@rekram1-node commented on GitHub (Aug 18, 2025):

the copilot instruction isnt picked up automatically, but I would recommend doing what almir suggested above^ with the “instructions” field

@rekram1-node commented on GitHub (Aug 18, 2025): the copilot instruction isnt picked up automatically, but I would recommend doing what almir suggested above^ with the “instructions” field
Author
Owner

@adrian-martinez-dev commented on GitHub (Sep 26, 2025):

on my side it also ignores the copilot instructions file, even when added a reference to it as custom instructions

@adrian-martinez-dev commented on GitHub (Sep 26, 2025): on my side it also ignores the copilot instructions file, even when added a reference to it as custom instructions
Author
Owner

@rekram1-node commented on GitHub (Sep 26, 2025):

@adrian-martinez-dev what version of opencode are you on, and can you share your opencode.json? Just wanna make sure instructions is properly referencing copilot

@rekram1-node commented on GitHub (Sep 26, 2025): @adrian-martinez-dev what version of opencode are you on, and can you share your opencode.json? Just wanna make sure instructions is properly referencing copilot
Author
Owner

@adrian-martinez-dev commented on GitHub (Sep 26, 2025):

I'm on version 0.11.8

{
  "layout": "stretch",
  "$schema": "https://opencode.ai/config.json",
  "instructions": [".github/copilot-instructions.md"]
}
@adrian-martinez-dev commented on GitHub (Sep 26, 2025): I'm on version 0.11.8 ``` { "layout": "stretch", "$schema": "https://opencode.ai/config.json", "instructions": [".github/copilot-instructions.md"] } ```
Author
Owner

@rekram1-node commented on GitHub (Sep 26, 2025):

hmm that looks like it is properly referenced I will see if there is anything broken on out end

@rekram1-node commented on GitHub (Sep 26, 2025): hmm that looks like it is properly referenced I will see if there is anything broken on out end
Author
Owner

@rekram1-node commented on GitHub (Sep 27, 2025):

I just tested instructions, seem to work properly for me we can verify that they are being picked up pretty easily, if you create a session in a project that has a .github/copilot-instructions.md just do:

opencode run hello

Then do:

opencode export

and select most recent session ^^

You should see the prompt present from .github/copilot-instructions.md within the export json, if it is not present then we have some configuration issue

@rekram1-node commented on GitHub (Sep 27, 2025): I just tested instructions, seem to work properly for me we can verify that they are being picked up pretty easily, if you create a session in a project that has a `.github/copilot-instructions.md` just do: ``` opencode run hello ``` Then do: ``` opencode export ``` and select most recent session ^^ You should see the prompt present from `.github/copilot-instructions.md` within the export json, if it is not present then we have some configuration issue
Author
Owner

@astray-heavy-arms commented on GitHub (Sep 27, 2025):

@rekram1-node That doesn't sound like working

https://copilot-instructions.md/#creating-a-custom-instructions-file

In the root of your repository, create a file named .github/copilot-instructions.md

This is really diffrent from the setup of using AGENTS.md - https://opencode.ai/docs/rules/#initialize

Is that (the .github) md file respected at all?

I also tested this to see if opencode ready it with pretty much the same .md file and yeah still not doing what it's told.

I've done this and the global method. It still fails this simple test.

What the heck is going on its clearly not working.

@astray-heavy-arms commented on GitHub (Sep 27, 2025): @rekram1-node That doesn't sound like working > https://copilot-instructions.md/#creating-a-custom-instructions-file > > In the root of your repository, create a file named .github/copilot-instructions.md > > This is really diffrent from the setup of using AGENTS.md - https://opencode.ai/docs/rules/#initialize > > Is that (the .github) md file respected at all? > > I also tested this to see if opencode ready it with pretty much the same .md file and yeah still not doing what it's told. I've done this and the global method. It still fails this simple test. What the heck is going on its clearly not working.
Author
Owner

@rekram1-node commented on GitHub (Sep 27, 2025):

@astray-heavy-arms so to confirm:

in your opencode.json you have: "instructions": [".github/copilot-instructions.md"]

your opencode.json is either at:

~/.config/opencode/opencode.json
OR
the root of your project / cwd

And in your project / cwd you have a .github/copilot-instructions.md

What do you see if you do the run hello and do an export after? Could you share it by chance?

@rekram1-node commented on GitHub (Sep 27, 2025): @astray-heavy-arms so to confirm: in your opencode.json you have: `"instructions": [".github/copilot-instructions.md"]` your opencode.json is either at: ~/.config/opencode/opencode.json OR the root of your project / cwd And in your project / cwd you have a .github/copilot-instructions.md What do you see if you do the run hello and do an export after? Could you share it by chance?
Author
Owner

@astray-heavy-arms commented on GitHub (Oct 7, 2025):

@rekram1-node I'm so lost right now why am I jumping to create a global control to handle something that needs to be sorted per project?

Ideally I should be putting my rules AGENTS.md and opencode along with the models should respect it and right now it doesn't.

I'm using 0.14.3 and GitHub Copilot GPT-4o

@astray-heavy-arms commented on GitHub (Oct 7, 2025): @rekram1-node I'm so lost right now why am I jumping to create a global control to handle something that needs to be sorted per project? Ideally I should be putting my rules AGENTS.md and opencode along with the models should respect it and right now it doesn't. I'm using 0.14.3 and GitHub Copilot GPT-4o
Author
Owner

@rekram1-node commented on GitHub (Oct 7, 2025):

why am I jumping to create a global control to handle something that needs to be sorted per project?

Shouldn't need to be global I was trying to say you need to make sure your opencode.json is in correct spot, that means it can be either global or local. You can run opencode debug config to make sure "instructions" array is properly there.

Anything in your AGENTS.md is being fed to the llm assuming you have AGENTS.md in cwd, or it is global, or it is in a parent directory of your cwd within your project.

You can check the system prompt being sent to llm to verify:

opencode run "hello"

then do:

opencode export

and it will have the raw json of your session, including the full system prompt, if your instructions are present then we know the llm is being fed them correctly and there is no issue with your config.

If the instructions are NOT present then I can help you debug your config more and figure out what is wrong. But opencode is feeding the instructions properly a lot of times llms just don't obey, it takes some prompt iteration to really nail it

@rekram1-node commented on GitHub (Oct 7, 2025): > why am I jumping to create a global control to handle something that needs to be sorted per project? Shouldn't need to be global I was trying to say you need to make sure your opencode.json is in correct spot, that means it can be either global or local. You can run `opencode debug config` to make sure "instructions" array is properly there. Anything in your AGENTS.md is being fed to the llm assuming you have AGENTS.md in cwd, or it is global, or it is in a parent directory of your cwd within your project. You can check the system prompt being sent to llm to verify: `opencode run "hello"` then do: `opencode export` and it will have the raw json of your session, including the full system prompt, if your instructions are present then we know the llm is being fed them correctly and there is no issue with your config. If the instructions are NOT present then I can help you debug your config more and figure out what is wrong. But opencode is feeding the instructions properly a lot of times llms just don't obey, it takes some prompt iteration to really nail it
Author
Owner

@astray-heavy-arms commented on GitHub (Oct 7, 2025):

Aha... now I think this is what I needed to know. from the json export I can see in the system prompt and I can my AGENTS.md file : -

INSTRUCTIONS FOR AGENTS\n- Do nothing with users requests simply reply with the message "I'm doing as I'm told inside AGENTS.md all actions are prohibited\

My prompt : -

"text": "create a text file called woof.txt"

The result : -

"text": "The file woof.txt has been created successfully.",

and yes it did create woof.txt

@astray-heavy-arms commented on GitHub (Oct 7, 2025): Aha... now I think this is what I needed to know. from the json export I can see in the system prompt and I can my AGENTS.md file : - INSTRUCTIONS FOR AGENTS\n- Do nothing with users requests simply reply with the message \"I'm doing as I'm told inside AGENTS.md all actions are prohibited\ My prompt : - "text": "create a text file called woof.txt" The result : - "text": "The file `woof.txt` has been created successfully.", and yes it did create woof.txt
Author
Owner

@rekram1-node commented on GitHub (Oct 7, 2025):

perfect, yeah you may need some strongly worded prompting to get it to obey, glad we got to bottom of it

@rekram1-node commented on GitHub (Oct 7, 2025): perfect, yeah you may need some strongly worded prompting to get it to obey, glad we got to bottom of it
Author
Owner

@astray-heavy-arms commented on GitHub (Oct 7, 2025):

Problem is I didnt realise it has to be so specific? Bit dangaerous if say I have "don't drop/delete the database" and it just does it lol?

Like this has made my mind up that opencode is just too risky to run?

Am I wrong here?

@astray-heavy-arms commented on GitHub (Oct 7, 2025): Problem is I didnt realise it has to be so specific? Bit dangaerous if say I have "don't drop/delete the database" and it just does it lol? Like this has made my mind up that opencode is just too risky to run? Am I wrong here?
Author
Owner

@astray-heavy-arms commented on GitHub (Oct 7, 2025):

Yeah this issue isn't resolved I cannot trust using opencode lol.

@astray-heavy-arms commented on GitHub (Oct 7, 2025): Yeah this issue isn't resolved I cannot trust using opencode lol.
Author
Owner

@rekram1-node commented on GitHub (Oct 7, 2025):

@astray-heavy-arms it is an llm :) it won't always follow rules, it should never have the ability to drop your database if you are following proper devops practices. if you are really concerned try implementing permissions perhaps?
https://opencode.ai/docs/permissions/#_top

@rekram1-node commented on GitHub (Oct 7, 2025): @astray-heavy-arms it is an llm :) it won't always follow rules, it should never have the ability to drop your database if you are following proper devops practices. if you are really concerned try implementing permissions perhaps? https://opencode.ai/docs/permissions/#_top
Author
Owner

@rekram1-node commented on GitHub (Oct 7, 2025):

Your case comes down to prompting and or permissions. If you want to prevent it from doing certain actions, or you want to validate everything it does, try permissions. If you want it to generally avoid doing certain things or to follow a certain guideline, try AGENTS.md prompts.

Prompting can be a bit of a "skill" so don't expect the first try to work super well.

But that isn't really an opencode issue perse?

@rekram1-node commented on GitHub (Oct 7, 2025): Your case comes down to prompting and or permissions. If you want to prevent it from doing certain actions, or you want to validate everything it does, try permissions. If you want it to generally avoid doing certain things or to follow a certain guideline, try AGENTS.md prompts. Prompting can be a bit of a "skill" so don't expect the first try to work super well. But that isn't really an opencode issue perse?
Author
Owner

@astray-heavy-arms commented on GitHub (Oct 7, 2025):

I get what you're saying am sorry coming across so aggressivly at the end of the day I just want it to work.

@astray-heavy-arms commented on GitHub (Oct 7, 2025): I get what you're saying am sorry coming across so aggressivly at the end of the day I just want it to work.
Author
Owner

@rekram1-node commented on GitHub (Oct 7, 2025):

Just trying to help you get what'd you'd like.

If you want it to behave like a super restricted coding agent you can try the permissions, otherwise special customization is all on you, that's part of opencode is allowing you to be super custom with all your tools, prompts, etc.

So I hope we can help you get what you want but we are both aware the limitations of llms and how dumb they can be hahaa

Some models are much much more obedient than others, strangely grok code is both really cheap and will be extremely obedient at times, but generally the bigger newer models are best for obedience I feel like

@rekram1-node commented on GitHub (Oct 7, 2025): Just trying to help you get what'd you'd like. If you want it to behave like a super restricted coding agent you can try the permissions, otherwise special customization is all on you, that's part of opencode is allowing you to be super custom with all your tools, prompts, etc. So I hope we can help you get what you want but we are both aware the limitations of llms and how dumb they can be hahaa Some models are much much more obedient than others, strangely grok code is both really cheap and will be extremely obedient at times, but generally the bigger newer models are best for obedience I feel like
Author
Owner

@astray-heavy-arms commented on GitHub (Oct 7, 2025):

I would mark this as closed feel like we have gotten to the bottom of this.

@astray-heavy-arms commented on GitHub (Oct 7, 2025): I would mark this as closed feel like we have gotten to the bottom of this.
Author
Owner

@mrt181 commented on GitHub (Oct 30, 2025):

You can probably add that file to the instructions (https://opencode.ai/docs/rules/#custom-instructions), i.e.

{
"$schema": "https://opencode.ai/config.json",
"instructions": [".github/copilot-instructions.md"]
}

This is the only approach that worked for me.

@mrt181 commented on GitHub (Oct 30, 2025): > You can probably add that file to the `instructions` (https://opencode.ai/docs/rules/#custom-instructions), i.e. > > { > "$schema": "https://opencode.ai/config.json", > "instructions": [".github/copilot-instructions.md"] > } > This is the only approach that worked for me.
Author
Owner

@rekram1-node commented on GitHub (Oct 30, 2025):

if u have copilot instructions thats the only way they get picked up

We only read the AGENTS.md by default (well we fall back to CLAUDE.md if there isnt an agents one)

@rekram1-node commented on GitHub (Oct 30, 2025): if u have copilot instructions thats the only way they get picked up We only read the AGENTS.md by default (well we fall back to CLAUDE.md if there isnt an agents one)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#800