Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Context Scoping Strategies

Scoping controls what knowledge your agent sees. Tighter scoping means more relevant results.

Three Levels of Scoping

Graph-Level Scoping

Separate graphs isolate knowledge entirely. Use different graph IDs for different projects, teams, or environments. Knowledge in one graph never leaks into another.

{
  "tool": "retrieve_memories",
  "arguments": {
    "query": "authentication patterns",
    "graph_id": "project-alpha"
  }
}

Graph-level scoping is the coarsest filter. Use it when knowledge domains are completely independent.

Type-Level Scoping

Filter by context_types to retrieve only specific categories of knowledge. This narrows the search space before semantic matching begins.

{
  "tool": "retrieve_memories",
  "arguments": {
    "query": "common mistakes",
    "context_types": { "error": [] }
  }
}

Pass an empty array to match all names within that type. Pass specific names to narrow further.

Name-Level Scoping

Filter by exact context_ids to retrieve knowledge from specific contexts only.

{
  "tool": "retrieve_memories",
  "arguments": {
    "query": "best practices",
    "context_ids": ["skill:react_hooks", "skill:typescript_generics"]
  }
}

Name-level scoping is the most precise. Use it when you know exactly which contexts are relevant.

Combining Filters

Filters stack. Combine type-level and name-level scoping for precise retrieval.

Example: Retrieve only error patterns from the current project.

{
  "tool": "retrieve_memories",
  "arguments": {
    "query": "recurring bugs in payment flow",
    "context_types": { "error": ["payment_null", "payment_timeout"] }
  }
}

Start broad and narrow down. If your agent retrieves too much noise, add a type filter. If results are still noisy, scope to specific context names.

Scoping Strategy by Use Case

Use CaseScope
General agent knowledgeNo filters (graph-wide search)
Task-specific wisdomType filter (skill:, error:)
Session continuityName filter (session:2025_03_19)
Cross-project patternsGraph-level separation + type filter
Debugging a specific moduleName filter (error:auth_module)

Next

Relevance & Retrieval
Understand semantic search, ranking, and confidence.
Contexts & Graphs
How contexts and graphs organize knowledge.