continuedev / continue

⏩ Continue is the leading open-source AI code assistant. You can connect any models and any context to build custom autocomplete and chat experiences inside VS Code and JetBrains
https://docs.continue.dev/
Apache License 2.0
19.25k stars 1.66k forks source link

Edit mode allows `@file` context but does not send context to server #2908

Open hamiltont opened 3 days ago

hamiltont commented 3 days ago

Before submitting your bug report

Relevant environment info

- OS: macOS
- Continue version: v0.8.56
- IDE version: VSCode Version: 1.95.1 Commit: 65edc4939843c90c34d61f4ce11704f09d3e5cb6
- Model: Claude Sonnet 3.5
- config.json:

{
  "models": [
    {
      "model": "claude-3-5-sonnet-20240620",
      "provider": "anthropic",
      "apiKey": "<removed>",
      "title": "Claude 3.5 Sonnet",
      "apiBase": "https://anthropic.helicone.ai/v1",
      "requestOptions": {
        "headers": {
            "Helicone-Auth": "<removed>",
            "Helicone-User-Id": "vscode"
        }
      },
      "systemMessage": "Generate only new/modified code segments. For existing code, use '// ... existing code'. Format each code block with:\n1. Filename as a comment header\n2. Only changes/additions\n3. Clear indicators of where changes belong\n\nSkip full file contents unless explicitly requested. Use markdown code blocks with language tags"
    },
    {
      "model": "claude-3-haiku-20240307",
      "systemMessage": "Generate only new/modified code segments. For existing code, use '// ... existing code'. Format each code block with:\n1. Filename as a comment header\n2. Only changes/additions\n3. Clear indicators of where changes belong\n\nSkip full file contents unless explicitly requested. Use markdown code blocks with language tags",
      "provider": "anthropic",
      "apiKey": "<removed>",
      "title": "Claude 3 Haiku",
      "apiBase": "https://anthropic.helicone.ai/v1",
      "requestOptions": {
        "headers": {
            "Helicone-Auth": "<removed>",
            "Helicone-User-Id": "vscode"
        }
      }
    }
  ],
  "tabAutocompleteModel": {
    "title": "Codestral",
    "provider": "mistral",
    "model": "codestral-latest",
    "apiKey": ""
  },
  "customCommands": [
    {
      "name": "test",
      "prompt": "{{{ input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
      "description": "Write unit tests for highlighted code"
    }
  ],
  "contextProviders": [
    {
      "name": "code",
      "params": {}
    },
    {
      "name": "docs",
      "params": {}
    },
    {
      "name": "diff",
      "params": {}
    },
    {
        "name": "repo-map"
    },
    {
      "name": "terminal",
      "params": {}
    },
    {
      "name": "problems",
      "params": {}
    },
    {
    "name": "os"
    },  
    {
        "name": "tree"
    },
    {
      "name": "folder",
      "params": {
        "nRetrieve": 100,
        "nFinal": 10,
        "useReranking": true
      }
    },
    {
      "name": "codebase",
      "params": {
        "nRetrieve": 100,
        "nFinal": 5,
        "useReranking": true
      }
    }
  ],
  "slashCommands": [
    {
      "name": "edit",
      "description": "Edit selected code"
    },
    {
      "name": "comment",
      "description": "Write comments for the selected code"
    },
    {
      "name": "share",
      "description": "Export the current chat session to markdown"
    },
    {
      "name": "cmd",
      "description": "Generate a shell command"
    },
    {
      "name": "commit",
      "description": "Generate a git commit message"
    }
  ],
  "experimental": {
    "modelRoles": {
      "repoMapFileSelection": "Claude 3 Haiku"
    }
  }
}

Description

Edit mode allows you to ender @file annotations, but the referenced files are not sent as context to the LLM

To reproduce

  1. Click Cmd+I to open chat in edit mode
  2. Reference a different file
  3. Note output API request does NOT include the @-referenced file
  4. Note the LLM response clearly shows it's not getting context

Example editing a schemas.py file was : Rewrite this sqlalchemy schema file to match the contents of @schema.sql

Outbound API request was:

{
  "max_tokens": 4096,
  "model": "claude-3-5-sonnet-20240620",
  "stream": true,
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "```python\nimport logging\n\nlog = logging.getLogger(__name__)\n\nfrom sqlalchemy import JSON, Column, Integer, String\n\nfrom .storage import Base\n\n\nclass StoredProposal(Base):\n    __tablename__ = \"proposals\"\n\n    id = Column(Integer, primary_key=True, index=True)\n    core = Column(JSON)\n    tags = Column(JSON)\n    type = Column(String, default=\"tr\")\n[BLANK]\n```\n\nAbove is the file of code that the user is currently editing in. Their cursor is located at the \"[BLANK]\". They have requested that you fill in the \"[BLANK]\" with code that satisfies the following request:\n\n\"Rewrite this sqlalchemy schema file to match the contents of schema.sql \"\n\nPlease generate this code. Your output will be only the code that should replace the \"[BLANK]\", without repeating any of the prefix or suffix, without any natural language explanation, and without messing up indentation. Here is the code that will replace the \"[BLANK]\":"
        }
      ]
    }
  ]
}

Log output

No response