> For the complete documentation index, see [llms.txt](https://docs.neohive.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.neohive.ai/core-concepts/retrieval.md).

# How retrieval works

What happens between your agent asking a question and NeoHive answering it, and the parts you control.

Recall is how your agent gets context from NeoHive while the agent works. The agent asks in plain words, and NeoHive answers from every [Index](/reference/glossary.md#index) in your [Hive](/reference/glossary.md#hive) at once. The answer is one list of matching code, docs, and [Memories](/reference/glossary.md#memory). Knowing what one recall does shows you which of your choices improve the results. The following diagram shows one recall:

<figure><img src="https://3192197639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4OPHduIiSuhnAhSI2yPb%2Fuploads%2Fgit-blob-b7114dfce18e246fbb008e53fe1992a12b25f008%2Fconcepts-retrieval.svg?alt=media" alt="Your agent asks in plain words, every Index in the Hive finds matches, and one list of whole sections comes back."><figcaption></figcaption></figure>

## What one recall does

In one recall, NeoHive does the following:

1. **Searches every Index at once.** The search includes any [Shared Index](/reference/glossary.md#shared-index). A paused Index, or one with an error, is left out.
2. **Matches meaning and exact words.** A description finds text about the same thing, even when that text uses different words. A function name or an error code finds the text that contains that name or code.
3. **Ranks the matches into one list.** How well a match fits the query counts most. A result with a higher [importance](/reference/glossary.md#importance) ranks higher. So does a result that your agents added or recalled recently.
4. **Returns whole sections.** A match in a document returns the whole section under its heading. A match in code returns the whole file, or the start of a long file, up to 200 lines.
5. **Lists each section once.** A section appears once even when several parts of the section match.

When your agent searches the whole Hive, each result shows the ID of the Index it came from. For everything else a result shows, see [`memory_recall`](/reference/mcp-tools.md#memory_recall).

## Two ways to ask

Your agent can ask in two ways:

* **At the start of a task.** `memory_context` returns the directives and conventions that match the task you describe, then decisions, known problems, and other notes. Most code does not come back from `memory_context`.
* **For code, or a specific question mid-task.** `memory_recall` searches for the query your agent writes and returns the best matches.

Both tools search every Index unless you name one.

{% hint style="info" %}
In Claude Code, the plugin also calls `memory_recall` with each prompt you send. For more information, see [What the plugin does automatically](/get-better-results/plugin-automation.md).
{% endhint %}

## What you control

NeoHive sets the order. You choose what to ask and where to look, and your agent turns your words into these `memory_recall` parameters:

| To                               | Parameter | How it helps                                                                                                                                                   |
| -------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Find more of what you need       | `queries` | Takes several phrasings of the same need. Different phrasings match different text.                                                                            |
| Search one Index only            | `index`   | Makes the search faster and more focused when you know which Index holds the answer.                                                                           |
| Get only certain kinds of result | `types`   | Keeps only the types you name, such as `directive` and `convention`. NeoHive also gives each section of code and docs a type, so those sections can match too. |
| Get more or fewer results        | `limit`   | Sets how many results come back.                                                                                                                               |

For more information about each parameter, its default, and its limits, see [MCP tools](/reference/mcp-tools.md).

When you do not know which Index holds the answer, search the whole Hive first, and note the Index ID on the best results. Then repeat the query with `index` set to that ID.

The phrasing of a query also matters. Name the tool and the problem, not only the topic. For example, instead of:

```
how do I fix GitHub Actions
```

Write:

```
GitHub Actions concurrency limit workaround
```

## Put it into practice

If you already added your repositories and documents, you can skip **Add your context** and go to [Write prompts that retrieve well](/get-better-results/prompting.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.neohive.ai/core-concepts/retrieval.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
