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 Case | Scope |
|---|---|
| General agent knowledge | No filters (graph-wide search) |
| Task-specific knowledge | Type filter (skill:, error:) |
| Session continuity | Name filter (session:2025_03_19) |
| Cross-project patterns | Graph-level separation + type filter |
| Debugging a specific module | Name filter (error:auth_module) |
| Multi-agent collaboration | Type filter on agent:<role> |
Anti-Patterns
| Anti-pattern | Why it hurts |
|---|---|
| One giant graph for everything | Retrieval quality drops as unrelated knowledge competes for ranking |
| Random per-call context names | Repeated events cannot reinforce each other and never graduate |
Filtering only by graph_id for everything | You miss the leverage of type-level recall on skill: and error: |