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 structured agent knowledge your agent sees in a given retrieval. Tighter scoping means more relevant, higher-confidence results.

Why Scope First

The fastest way to make an agent dumber is to give it everything. The fastest way to make it sharper is to give it the right slice. LocusGraph offers three scoping layers that combine cleanly: graph, type, and name.

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 knowledgeType 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)
Multi-agent collaborationType filter on agent:<role>

Anti-Patterns

Anti-patternWhy it hurts
One giant graph for everythingRetrieval quality drops as unrelated knowledge competes for ranking
Random per-call context namesRepeated events cannot reinforce each other and never graduate
Filtering only by graph_id for everythingYou miss the leverage of type-level recall on skill: and error:

Next

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