Context Filtering

Manage Cody Context

Control and manage what context from your codebase is used by Cody with Context Filters.

Context Filters

Context Filters are available only for Enterprise users on all supported clients. Admins can use these filters to determine which repositories Cody can use as context in its requests to third-party LLMs.

Requirements

  • A valid Cody Enterprise license running on Sourcegraph instance version >=5.4.0
  • Supported Cody client versions: VS Code >=1.20.0 and JetBrains >=6.0.0
  • Set the cody-context-filters-enabled feature flag to true

Configuration Example

Site admins can customize the cody.contextFilters field in the site configuration to specify which repositories Cody should include or exclude:

JSON Configuration
{
              "cody.contextFilters": {
                "include": [
                  { "repoNamePattern": "^github\\.com\\/sourcegraph\\/.*" }
                ],
                "exclude": [
                  { "repoNamePattern": ".*analytics.*" }
                ]
              }
            }

How Include and Exclude Rules Work

The include and exclude rules define which repositories Cody can use as context. Here's how they work:

  • No Rules Defined: Cody can access all repositories by default.
  • Only Include Rules: Cody is restricted to repositories matching the include patterns.
  • Only Exclude Rules: Cody excludes repositories matching the exclude patterns.
  • Both Include and Exclude Rules: Cody uses repositories matching the include patterns but excludes those matching the exclude patterns.

Compatibility Matrix

Cody Context Filters work only on specific versions of Sourcegraph and supported clients. Below is a breakdown of compatibility:

Client Client Version Sourcegraph v<5.4.0 Sourcegraph v=5.4.0 Sourcegraph v>=5.4.0
VS Code >= 1.20.0 N/A Respects Policy Respects Policy
JetBrains >= 6.0.0 N/A Respects Policy Respects Policy

Next Steps