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 Case | Scope |
|---|---|
| General agent knowledge | No filters (graph-wide search) |
| Task-specific wisdom | 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) |