Skip to main content
Retrieval in Persona is a process of context construction, not document fetching. The goal is to assemble a coherent picture of the user that informs the LLM’s response.

Tuning Parameters

The retrieval process is controlled by two parameters:
ParameterEffect
top_kNumber of seed nodes from vector search. Increase for recall, decrease for precision.
hop_depthGraph traversal depth from seeds. 0 = pure vector. 1 = immediate neighbors (previous episode, source psyche). 2+ = deeper causal chains. Higher depths increase latency.

Static Context

Before any query processing, the system fetches “always-on” context. This currently includes:
  • Active Goals: All goals not marked COMPLETED.
  • Core Psyche: The first 5 psyche traits (traits, preferences, values).
This ensures the agent always knows the user’s current objectives and baseline identity, even if the query doesn’t mention them.

Why Graph Traversal Matters

Consider the query: “What happened before my meeting with Sarah?” Vector search can find documents mentioning “Sarah” and “meeting.” But it cannot answer “before.” Only graph traversal can follow the PREVIOUS edge to return the chronologically preceding episode. Similarly, a query about “why I’m stressed” might match an episode about stress. Graph traversal finds the derived_from link connecting that episode to a goal with an approaching deadline—the actual cause. This is the core value of the hybrid approach: vector finds the topic, graph finds the context.

Output Format

The final context is returned as structured XML to the LLM:
<memory_context>
  <goals>
    <task status="active">Finish Auth Module</task>
  </goals>
  <psyche>
    <trait>Prefers morning work sessions</trait>
  </psyche>
  <episodes>
    <episode date="Yesterday">
      I'm struggling with the Auth0 integration...
    </episode>
    <episode date="Two Days Ago">
      Decided to switch from Firebase to Auth0.
    </episode>
  </episodes>
</memory_context>
This format groups memories by type, giving the LLM a structured view of the user’s state, identity, and recent history.