Skip to main content
Deep Search is an agentic code search tool that understands natural language questions about your codebase. When you ask a question, Deep Search runs an in-depth, multi-step investigation across your repositories and returns a detailed, sourced answer. You can continue the conversation with follow-up questions to go deeper into relevant code. Under the hood, Deep Search is an AI agent that uses Sourcegraph’s Code Search and Code Navigation features as tools in an agentic loop. In each iteration, the agent refines its understanding of your question and codebase until it is confident in its answer. All processing happens within your Sourcegraph instance — only external calls are made to the configured LLM.
Deep Search is available on Enterprise Starter and Enterprise plans. It requires the Sourcegraph Model Provider and is not supported for BYOK (Bring Your Own Key) customers.
Code Search and Deep Search answer different kinds of questions.
Code SearchDeep Search
Interaction modelQuery-driven — you write a search expressionAgent-driven — you ask a natural language question
Best forExhaustive, precise lookups (find every occurrence of X)Understanding, reasoning, and explanation (how does X work?)
Result formatList of matching files and linesProse answer with linked sources
Follow-upRefine the query manuallyContinue the conversation naturally
CompletenessExhaustive across all matchesRepresentative sample used for reasoning
For exhaustive queries — “find every file with extension .proto containing the word auth” — Code Search is the right tool. Deep Search samples results to reason over them, so it will not guarantee completeness for large result sets.

Asking questions

Navigate to Deep Search from the Sourcegraph sidebar or top navigation. Type your question in the input field and press Enter.

Using @-mentions

Type @ at any point in your query to scope the search to specific repositories or files. Suggestions update in real time as you type.
  • @repository-name — restrict the agent to a specific repo
  • @path/to/file.go — point the agent at a particular file
The search is keyword-based and supports spaces. For example, @internal search.go finds files named search.go inside internal folders.
Give the agent a starting point. The more specific your @-mentions, the faster and more accurate the answer.

Example prompts

Find examples of logger usage and show examples of the different types of logging we use.
I want to know when the indexing queue functionality was last changed in @zoekt. Show me the last few commit diffs touching this code and explain the changes.
Look at the GraphQL APIs available in @sourcegraph/sourcegraph. Are any of them unused? The client code is in the @cody repository.
Generate a request flow diagram for src/backend. Mark the auth and rate limit points.
Which tools do we use in our build processes defined in BUILD.bazel files?

Reviewing results

Every Deep Search response includes:
  • A prose answer formatted in Markdown, with links to relevant files, directories, or repositories.
  • A sources list showing exactly which searches were performed and which files were read. Use this to verify the answer and identify gaps.
  • Suggested follow-ups to continue the investigation.
If something is missing from the answer, check the sources list and ask a follow-up that mentions the missing file or repository.

Use cases

Understanding unfamiliar code

Ask “How does authentication work in this service?” instead of manually tracing call stacks through dozens of files.

Architecture questions

Request diagrams and explanations of request flows, data models, or module boundaries across repositories.

Finding patterns

Ask “What patterns do we use for error handling?” to get a summarized answer with representative examples rather than raw search results.

Onboarding

Use Deep Search to ramp up on an unfamiliar codebase — ask “What is the overall structure of this repo?” or “How do I add a new API endpoint?”

Tracing changes over time

Ask Deep Search to summarize recent commits touching a specific area: “What changed in the payment module in the last month?”

Cross-repo dependencies

Investigate how multiple repositories interact: “Which services call the billing API and how do they authenticate?”

Conversation sharing

You can share a Deep Search conversation with other users in your Sourcegraph instance. Click the Share button in the top left to copy a shareable link. Any user on your instance can view the conversation via that link.
Repository permissions are not enforced for shared conversations. A user who receives a share link can view the conversation regardless of which repositories they have access to.
To reset the share link and invalidate the previous one, click Share again and generate a new link. Sharing is disabled by default. Ask your site administrator to enable it:
"deepSearch.sharing.enabled": true

Limitations and when to use Code Search instead

Use Code Search when you need:
  • Exhaustive results — every single match, not a representative sample
  • Structured queries — filtering by repo, language, file path, commit, or author
  • Speed — instant results without waiting for an agent loop
  • Regex or structural search — precise syntactic patterns
Use Deep Search when you need:
  • A natural language question answered with explanation
  • Reasoning across multiple files or repositories
  • An architectural overview or diagram
  • Understanding why code is written a certain way
If Deep Search is unavailable, ask your site administrator to add this to the site configuration:
"deepSearch.enabled": true
Deep Search uses frontier and specialized models selected and maintained by Sourcegraph. It requires the Sourcegraph Model Provider — it cannot be used with customer-managed (BYOK) model configurations.

Network requirements for self-hosted instances

Deep Search streams responses using Server-Sent Events (SSE). A single request can remain open for up to 5 minutes.
If your Sourcegraph instance is behind a reverse proxy, load balancer, or ingress controller, set the upstream timeout to at least 5 minutes. The default timeout of 30–60 seconds will cut off in-progress responses.

Code Search

Query-driven search across all your repositories with filters, regex, and structural search.

Cody

AI coding assistant for completions, chat, and inline edits directly in your editor.

Code Navigation

Jump to definition, find references, and hover documentation across repositories.

Admin overview

Configure Deep Search, manage entitlements, and monitor usage for your instance.

Build docs developers (and LLMs) love