Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.
This repository was archived by the owner on Sep 18, 2025. It is now read-only.

Doesn't follow some instructions in opencode.md #90

Closed

Description

@possibilities

I'm adding a line to opencode.md similar to:

  • Always use the Context7 MCP to look up information, best practices, code examples, and documentation for any software project, language, or framework.

It basically doesn't cause the the model to use the tool at all. But if I paste it into my opencode session before working it is always followed.

Should I expect this to work? Thanks! Loving the tool so far.

Activity

  1. kujtimiihoxha commented on Apr 27, 2025

    @kujtimiihoxha
    Contributor

    Does it follow the other instructions? I am wondering if OpenCode is loading the file or not. Also if that does not work maybe try to change the message to be more specific, usually claude does a good job following these kind of instructions

  2. possibilities commented on Apr 27, 2025

    @possibilities
    Author

    It works if it's the only line in opencode.md but when I put all the rules I want (32 lines total) it no longer works.

  3. possibilities commented on Apr 27, 2025

    @possibilities
    Author

    Feel free to close and I can try again after #86 is in. If it still doesn't work I'll learn more about debugging in go and try to figure it out. Thanks!

  4. kujtimiihoxha commented on Apr 27, 2025

    @kujtimiihoxha
    Contributor

    I think the issue is that it has not a lot to do with OpenCode directly, the LLM is just choosing not to care about that rule. Its more prompt engineering than go, I think if we make sure to tell the LLM that "hey you need to follow these rules" it will do it.

  5. possibilities commented on Apr 27, 2025

    @possibilities
    Author

    I've been avoiding diving into too much golang so far so tried a couple other things first:

    1. Verified with logging that the contents of opencode.md are being sent to sonnet
    2. Renaming it to CLAUDE.md and running the same prompt ("what is fast-agent?") triggers the tool

    Based on 2 I'll do some more poking next to see what's different between the two. I have a hunch that it could be related to the ordering of the prompt(s) content.

  6. kujtimiihoxha commented on Apr 27, 2025

    @kujtimiihoxha
    Contributor

    @possibilities we just merged #86 that explicitly tells the LLM to follow instructions in the context files, try it out again and let me know if it is better

  7. possibilities commented on Apr 27, 2025

    @possibilities
    Author
  8. possibilities commented on Apr 28, 2025

    @possibilities
    Author

    Still have the same issues with the latest.

    I tried rewriting the details about Context7 a number of different ways including adding the full documentation :

    - `resolve-library-id`: Resolves a general library name into a Context7-compatible library ID.
      - `libraryName` (required)
    - `get-library-docs`: Fetches documentation for a library using a Context7-compatible library ID.
      - `context7CompatibleLibraryID` (required)
      - `topic` (optional): Focus the docs on a specific topic (e.g., "routing", "hooks")
      - `tokens` (optional, default 5000): Max number of tokens to return. Values less than 5000 are automatically increased to 5000.
    

    But the only way the tool is ever used is when:

    1. The instructions are the only contents in opencode.md
    2. The instructions are pasted directly into opencode before any prompt

    With claude code it picks up on the instruction if it's somewhere in CLAUDE.md.

    In my opinion it's not behaving "correctly" but I think only you, as the author, can decide what's expected. Should I be able to guide tool use in opencode.md?

    Can you suggest a way of phrasing it that should trigger the tool to be used?

    BTW, I test this by opening a project and asking opencode "what's fast-agent?" with the context7 MCP installed.

  9. kujtimiihoxha commented on Apr 28, 2025

    @kujtimiihoxha
    Contributor

    How does your config look like? Did you add the mcp to opencode?

  10. possibilities commented on Apr 28, 2025

    @possibilities
    Author
    {
      "data": {
        "directory": ".opencode"
      },
      "providers": {
        "anthropic": {
          "disabled": false
        }
      },
      "agents": {
        "coder": {
          "model": "claude-3.7-sonnet",
          "maxTokens": 5000
        },
        "task": {
          "model": "claude-3.7-sonnet",
          "maxTokens": 5000
        },
        "title": {
          "model": "claude-3.7-sonnet",
          "maxTokens": 80
        }
      },
      "lsp": {
        "typescript": {
          "disabled": false,
          "command": "typescript-language-server",
          "args": ["--stdio"]
        }
      },
      "mcpServers": {
        "Context7": {
          "type": "stdio",
          "command": "npx",
          "args": ["-y", "@upstash/context7-mcp@latest"]
        }
      },
      "debug": false,
      "debugLSP": false
    }
    
  11. kujtimiihoxha commented on Apr 28, 2025

    @kujtimiihoxha
    Contributor

    I am wondering if fast-agent is just too generic, what if you say something what is the library fast-agent or something to tell it that your are talking about a library.

    Also maybe add something along the lines

    If you don't know exactly what I am talking about always use context7 to retrieve information
    

    Just a thought🤔

  12. possibilities commented on Apr 28, 2025

    @possibilities
    Author

    I am wondering if fast-agent is just too generic

    The test works well if there are only 1-5 lines in opencode.md (using your instruction or mine) but as soon as there are greater than 10 lines it is ignored.

    To me it seems like it should work but I don't want to distract you with this problem if it's unique to me. If it's an actual problem and not unique to me you will get other reports in the future.

    I appreciate all your attention on this but all for closing it if you are.

  13. kujtimiihoxha commented on Apr 28, 2025

    @kujtimiihoxha
    Contributor

    Thanks @possibilities, we can circle back to this again when i look into improving the prompts in general it is on my list

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