Skip to main content
A recall response is structured JSON. Your model wants prose. This page shows how to bridge that gap - turning a RetrievalResult into a clean, grounded prompt for an LLM. The same pattern works for full_recall, recall_preferences, and combinations of the two.

1. What you get back

The retrieval endpoints (full_recall and recall_preferences) return the same core response shape:
Four things matter for prompt construction:
  • chunks - the primary retrieval output. Ranked by relevance; preserve the order HydraDB returns.
  • graph_context.query_paths - entity traversal paths derived from your query. Useful for relational reasoning. See Context Graphs.
  • graph_context.chunk_relations + chunk_id_to_group_ids - per-chunk graph relations grouped by group_id, so you can attach the right triplets to each chunk.
  • additional_context - a map keyed by chunk_uuid. When a chunk includes extra_context_ids, use those IDs to look up related chunks here.
Don’t pass the raw object to the LLM. Convert it into a structured context string first.

2. Transforming the response into LLM context

The helper below takes a RetrievalResult and produces a single string with:
  1. Entity paths from graph_context.query_paths (when present)
  2. Ranked chunks in server order, each preceded by Source: <title>
  3. Graph relations per chunk, matched via chunk_id_to_group_idschunk_relations
  4. Extra context for any extra_context_ids attached to a chunk
The output is delimited by === ENTITY PATHS === and === CONTEXT === blocks so the LLM can read it cleanly. First, call the recall endpoint with the parameters you need:
Then pass the response into the helper below to build a context string:

3. Feeding the context into your LLM

Once you have a context string, call your model with a grounded system prompt:

4. Combining Knowledge and Memories

For personalised answers, run full_recall and recall_preferences in parallel, format each result, and combine them into one prompt. There’s no required ordering - preferences before docs is purely for readability.
If memory recall fails or times out, fall back to the Knowledge-only prompt - personalisation is an enhancement, not a hard dependency.

5. Practical guidance

  • Preserve server order. Don’t re-sort chunks client-side.
  • Start small on chunks. max_results: 10 is a reasonable default. Drop to 5 if you hit token limits, raise to 20 if you rerank downstream.
  • Use graph context selectively. It improves relational queries and bloats simple lookups. See Context Graphs.
  • Always ground the model. A system prompt like “answer only from the provided context” prevents the model from inventing answers when retrieval is thin.
  • Format consistently. Whatever section delimiters you choose (=== CONTEXT ===, Chunk N, Source:), keep them stable across calls so the model learns the structure.

6. Common mistakes