Skip to main content

Query context from the context tree

This guide walks you through querying context from your context tree using agentic search. There are two ways to query your context tree:
  • /query — Run directly in the ByteRover REPL for quick, manual lookups
  • brv query — Executed by your coding agent for integration into coding workflows. Can be run manually.
To query your context tree, copy this prompt and paste it into your coding agent’s chat (e.g., Cursor, Claude Code, etc.):
Your coding agent will then execute the command:
When the command runs, ByteRover intelligently searches your context tree using a multi-tier strategy that combines BM25 full-text search, compound scoring, and multi-step reasoning. Example:

How Query Works

ByteRover routes every query through a 5-tier strategy, starting with the fastest path and escalating only when needed: Tiers 0-2 bypass the LLM entirely for speed. Most repeated or well-covered queries resolve in under 200ms. For full details on each tier and out-of-domain detection, see How Query Works.

Compound Scoring

Search results are ranked using a formula that balances text relevance, accumulated importance, and freshness:
Mature knowledge files (core tier) receive a 1.15× boost, while draft files receive a 0.85× penalty — well-established context surfaces above newer drafts even with slightly lower text relevance. Results below 70% of the top score are automatically dropped.

Path-Scoped Queries

You can scope queries to a specific domain or topic by including a path:
The first word (or slash-separated prefix) is detected as a scope, and the remaining text is used as the search query within that scope. For the full scoring formula and path-scoping rules, see How Query Works.

Manual Query via /query

You can also query the context tree directly in the ByteRover REPL using the /query command:
This runs the query immediately without going through your coding agent. Example output:

When to Use /query vs Agent Prompts

Use /query when you want to quickly check what knowledge is available before starting a task. Use agent prompts when the retrieved context should flow directly into your coding workflow.

What Makes This Intelligent?

Multi-tier strategy: ByteRover doesn’t use a single retrieval method. It combines exact caching, BM25 full-text search with compound scoring, LLM-assisted pre-fetch, and full agentic reasoning — routing each query to the fastest tier that can produce a quality answer. Follows explicit relations: ByteRover follows the @domain/topic relations between topics to gather comprehensive, connected context. Synthesizes information: Instead of returning ranked documents, ByteRover reads relevant context files and synthesizes a coherent answer with citations. Context-aware answers: You get understanding, not just matches. ByteRover comprehends your query semantically and provides relevant, actionable information. Out-of-domain detection: When your query falls outside the knowledge stored in the context tree, ByteRover tells you rather than returning a low-quality guess, and suggests curating relevant knowledge first. For details on query tiers, compound scoring, and path-scoped queries, see How Query Works.

Multi-Step Queries

For complex tasks requiring different types of context, you can run multiple queries: Copy this prompt and paste it into your coding agent’s chat:
Your coding agent will then execute:

Crafting Effective Queries

The quality of your results depends on your query. Here are some tips: Specific queries work better:
vs. vague queries:
Include technical details:
Reference specific patterns or technologies:
Note: While ByteRover understands semantic meaning, specific and detailed queries still produce better results because they help focus the search.

You’re in Control of Your Queries

The brv query command is flexible and adapts to how you want to work:

Broad Exploration

Want to see everything related to a topic? Use a general query: Copy this prompt and paste it into your coding agent’s chat:
Your coding agent will execute:
ByteRover explores relations across topics to give you a comprehensive view of all authentication-related knowledge.

Focused Retrieval

Need specific implementation details? Be more precise: Copy this prompt and paste it into your coding agent’s chat:
Your coding agent will execute:
ByteRover searches specific domains and topics for targeted information.