Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 0 additions & 73 deletions docs/cody/capabilities/agentic-chat.mdx

This file was deleted.

119 changes: 119 additions & 0 deletions docs/cody/capabilities/agentic-context-fetching.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Agentic Context Fetching

<p className= "subtitle"> Learn about agentic context fetching, a mini-agent that uses search and tools to retrieve context.</p>

Cody's agentic context fetching experience can evaluate context and fetch any additional context (MCP, OpenCtx, terminal, etc.) by providing enhanced, context-aware chat capabilities. It extends Cody's functionality by proactively understanding your coding environment and gathering relevant information based on your requests before responding. These features help you get noticeably higher-quality responses.

This experience aims to reduce the learning curve associated with traditional coding assistants by minimizing users' need to provide context manually. It achieves this through agentic context retrieval, where the AI autonomously gathers and analyzes context before generating a response.

## Capabilities of agentic chat

The agentic context fetching experience leverages several key capabilities, including:

- **Proactive context gathering**: Automatically gathers relevant context from your codebase, project structure, and current task
- **Agentic context reflection**: Review the gathered context to ensure it is comprehensive and relevant to your query
- **Iterative context improvement**: Performs multiple review loops to refine the context and ensure a thorough understanding
- **Enhanced response accuracy**: Leverages comprehensive context to provide more accurate and relevant responses, reducing the risk of hallucinations

## What can agentic context fetching do?

Agentic context fetching can help you with the following:

### Tool Usage

It has access to a suite of tools for retrieving relevant context. These tools include:

- **Code Search**: Performs code searches
- **Codebase File**: Retrieves the full content from a file in your codebase
- **Terminal**: Executes shell commands in your terminal
- **Web Browser**: Searches the web for live context
- **MCP**: (Configure MCP and add servers)[] to fetch external context
- **OpenCtx**: Any OpenCtx providers could be used by the agent

It integrates seamlessly with external services, such as web content retrieval and issue tracking systems, using OpenCtx providers. To learn more, [read the OpenCtx docs](/cody/capabilities/openctx).

<Callout type= "info">Terminal access is not supported on the Web. It currently only works with VS Code, JetBrains, and Visual Studio editor extensions.</Callout>

## Terminal access

Agentic context fetching can use the CLI Tool to request the execution of shell commands to gather context from your terminal. Its ability to execute terminal commands enhances its context-gathering capabilities. However, it's essential to understand that any information accessible via your terminal could potentially be shared with the LLM. It's recommended not to request information that you don't want to share. Here's what you should consider:

- **Requires user consent**: Agentic context fetching will pause and ask for permission each time before executing any shell command.
- **Trusted workspaces only**: Commands can only be executed within trusted workspaces with a valid shell
- **Potential data sharing**: Any terminal-accessible information may be shared with the LLM

Commands are generated by the agent/LLM based on your request. Avoid asking it to execute destructive commands.

## Use cases

Agentic context fetching can be helpful to assist you with a wide range of tasks, including:

- **Improved response quality**: Helps you get better and more accurate responses than other LLMs, making up for the additional processing time for context gathering a non-issue
- **Error resolution**: It can automatically identify error sources and suggest fixes by analyzing error logs
- **Better unit tests**: Automatically includes imports and other missing contexts to generate better unit tests

## Enable agentic context fetching

Agentic context fetching is enabled by default for all Cody users. It uses LLM reflection and basic tool use steps to gather and refine context before sending it in the final model query. The review step in agentic context fetching experience defaults to Gemini 2.5 Flash and falls back to Claude Haiku or GPT 4.1 mini if Flash is unavailable.

If a user doesn't have any of these models, the agentic context fetching experience will use the model selected from the model dropdown for the final output.

Terminal access for Enterprise users is disabled by default. To enable it, set the `agentic-chat-cli-tool-experimental` feature flag [terminal access](#terminal-commands).

## MCP support

MCP (Model Context Protocol) tools are supported by agentic context fetching to connect to the external context. Users can configure multiple local MCP servers via their Cody's extension settings. Based on your query, agentic context will determine which MCP tools to invoke and what parameters to provide to the tools. Agentic context fetching experience will execute these tools and inject the context from the tool calls into Cody's context window.

### Setting up MCP tools

MCP is disabled by default. To enable it, add the `agentic-chat-mcp-enabled` feature flag to your Enterprise Sourcegraph instance.

Once MCP is enabled, there are two ways to configure an MCP server:

#### 1. From the editor extension UI

To configure an MCP server from the editor extension UI, click your profile icon in the Cody extension and select the **MCP Settings** option.

![mcp-via-ui](https://storage.googleapis.com/sourcegraph-assets/Docs/mcp-with-ui-2025.png)

Create a new server configuration and input the necessary arguments provided by the server. You can disable individual tools in the UI by clicking on them.

#### 2. From the editor extension settings

- Edit your MCP configuration settings using the `cody.mcpServers` property in your extension settings.
- `settings.json` (VSCode)
- `cody_settings.json` (JetBrains)
- Use the following format when adding a new server

<Callout type= "tip">In JetBrains, you need the absolute path to the command. Use the `which` command in the terminal to find it. For example, `which npx`.</Callout>

```json
"cody.mcpServers": {
"<server_name>": {
"command": "...",
"args": [...],
"env": {
...
},
"disabledTools": [...]
}
}
```

When you submit a query, Cody will determine whether to use any of the server's tools.

![mcp-via-settings](https://storage.googleapis.com/sourcegraph-assets/Docs/mcp-via-settings.png)

### MCP Best Practices

Since MCP is an open protocol and servers can be created by anyone, your mileage may vary. Tool names, descriptions, and the underlying models you have available may all affect the performance of MCP retrieval. To get the best results using your MCP servers, it's recommended the following:

- Read through the tools of the servers you install and their parameters. Be as explicit as possible in your queries to provide all of the information the tool needs
- If you don't get the desired results on the first try, iterate on your query. It may take a couple of tries to get the results you're expecting
- Choose high-quality servers. Prefer servers from official sources over third parties. Read through the code to understand how the servers you are installing work

### Limitations

- Cody currently supports only local MCP servers
- MCP offers three main capabilities: Tools, Resources, and Prompts. Currently, Cody supports only Tools
- Since most MCP servers require users to create their access tokens, the servers will have the same access as whatever token you provide. For example, if a user has write permissions to Jira and creates an access token with write permissions, they can use Cody to write back into Jira via MCP. It is impossible to limit write access across all MCP tools broadly. You should use tools with this consideration in mind
11 changes: 6 additions & 5 deletions docs/cody/clients/feature-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
| @-file | ✅ | ✅ | ✅ | ✅ | ❌ |
| @-symbol | ✅ | ❌ | ✅ | ✅ | ❌ |
| LLM Selection | ✅ | ✅ | ✅ | ✅ | ❌ |
| Agentic Context Fetching | ✅ | ✅ | ✅ | ✅ | ✅ |
| **Context Selection** | | | | | |
| Single-repo context | ✅ | ✅ | ✅ | ✅ | ❌ |
| Multi-repo context | ❌ | ❌ | ❌ | ✅ (public code only) | ❌ |
Expand All @@ -26,11 +27,11 @@

## Code Autocomplete and Auto-edit

| **Feature** | **VS Code** | **JetBrains** | **Visual Studio** |
| ------------------------------------------------------ | ----------- | ------------- | ----------------- |
| Single and multi-line autocompletion | ✅ | ✅ | ✅ |
| Cycle through multiple completion suggestions | ✅ | ✅ | ✅ |
| Accept suggestions word-by-word | ✅ | ❌ | ❌ |
| **Feature** | **VS Code** | **JetBrains** | **Visual Studio** |
| ----------------------------------------------------- | ----------- | ------------- | ----------------- |
| Single and multi-line autocompletion | ✅ | ✅ | ✅ |
| Cycle through multiple completion suggestions | ✅ | ✅ | ✅ |
| Accept suggestions word-by-word | ✅ | ❌ | ❌ |
| Auto-edit suggestions via cursor movements and typing | ✅ | ✅ | ❌ |

Few exceptions that apply to Cody Pro and Cody Enterprise users:
Expand Down
2 changes: 1 addition & 1 deletion src/data/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const navigation: NavigationItem[] = [
subsections: [
{ title: "Chat", href: "/cody/capabilities/chat", },
{ title: "Query Types", href: "/cody/capabilities/query-types", },
{ title: "Agentic chat", href: "/cody/capabilities/agentic-chat", },
{ title: "Agentic Context Fetching", href: "/cody/capabilities/agentic-context-fetching", },
{ title: "Autocomplete", href: "/cody/capabilities/autocomplete", },
{ title: "Auto-edit", href: "/cody/capabilities/auto-edit", },
{ title: "Prompts", href: "/cody/capabilities/prompts", },
Expand Down
9 changes: 8 additions & 1 deletion src/data/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6795,7 +6795,14 @@ const redirectsData = [
source: "/analytics/self-hosted",
destination: "/analytics/air-gapped",
permanent: true
}
},

//Agentic chat redirect
{
source: "/cody/capabilities/agentic-chat",
destination: "/cody/capabilities/agentic-context-fetching",
permanent: true
},


];
Expand Down