askill
retrieval-policy

retrieval-policySafety 95Repository

Agent retrieval policy for intelligent memory search. Use when implementing memory queries to detect capabilities, classify intent, route through optimal layers, and handle fallbacks. Provides tier detection, intent classification, fallback chains, and full explainability for all retrieval operations.

3 stars
1.2k downloads
Updated 2/13/2026

Package Files

Loading files...
SKILL.md

Retrieval Policy Skill

Intelligent retrieval decision-making for agent memory queries. The "brainstem" that decides how to search.

When to Use

Use CaseBest Approach
Detect available search capabilitiesretrieval status
Classify query intentretrieval classify <query>
Route query through optimal layersretrieval route <query>
Understand why a method was chosenCheck explainability payload
Handle layer failures gracefullyAutomatic fallback chains

When Not to Use

  • Direct search operations (use memory-query skill)
  • Topic exploration (use topic-graph skill)
  • BM25 keyword search (use bm25-search skill)
  • Vector semantic search (use vector-search skill)

Quick Start

# Check retrieval tier
memory-daemon retrieval status

# Classify query intent
memory-daemon retrieval classify "What JWT issues did we have?"

# Route query through layers
memory-daemon retrieval route "authentication errors last week"

Capability Tiers

The system detects available layers and maps to tiers:

TierNameLayers AvailableDescription
1FullTopics + Hybrid + AgenticComplete cognitive stack
2HybridBM25 + Vector + AgenticKeyword + semantic
3SemanticVector + AgenticEmbeddings only
4KeywordBM25 + AgenticText matching only
5AgenticAgentic onlyTOC navigation (always works)

Tier Detection

memory-daemon retrieval status

Output:

Retrieval Capabilities
----------------------------------------
Current Tier:    2 (Hybrid)
Available Layers:
  - bm25:    healthy (2847 docs)
  - vector:  healthy (2103 vectors)
  - agentic: healthy (TOC available)
Unavailable:
  - topics:  disabled (topics.enabled = false)

Query Intent Classification

Queries are classified into four intents:

IntentTriggersOptimal Strategy
Explore"browse", "discover", "what topics"Topics-first, broad fan-out
Answer"what did", "how did", "find"Hybrid, precision-focused
LocateIdentifiers, exact phrases, quotesBM25-first, exact match
Time-boxed"yesterday", "last week", datesTime-filtered, sequential

Classification Command

memory-daemon retrieval classify "What JWT issues did we debug last Tuesday?"

Output:

Query Intent Classification
----------------------------------------
Intent:          Answer
Confidence:      0.87
Time Constraint: 2026-01-28 (last Tuesday)
Keywords:        [JWT, issues, debug]
Suggested Mode:  Hybrid (BM25 + Vector)

Fallback Chains

Each tier has a predefined fallback chain:

Tier 1: Topics → Hybrid → Vector → BM25 → Agentic
Tier 2: Hybrid → Vector → BM25 → Agentic
Tier 3: Vector → BM25 → Agentic
Tier 4: BM25 → Agentic
Tier 5: Agentic (no fallback needed)

Fallback Triggers

ConditionAction
Layer returns 0 resultsTry next layer
Layer timeout exceededSkip to next layer
Layer health check failedSkip layer entirely
Min confidence not metContinue to next layer

Stop Conditions

Control query execution with stop conditions:

ConditionDefaultDescription
max_depth3Maximum drill-down levels
max_nodes50Maximum nodes to visit
timeout_ms5000Query timeout in milliseconds
beam_width3Parallel branches to explore
min_confidence0.5Minimum result confidence

Intent-Specific Defaults

Intentmax_nodestimeout_msbeam_width
Explore100100005
Answer5050003
Locate2030001
Time-boxed3040002

Execution Modes

ModeDescriptionBest For
SequentialOne layer at a time, stop on successLocate intent, exact matches
ParallelAll layers simultaneously, merge resultsExplore intent, broad discovery
HybridPrimary layer + backup, merge with weightsAnswer intent, balanced results

Explainability Payload

Every retrieval returns an explanation:

{
  "tier_used": 2,
  "tier_name": "Hybrid",
  "intent": "Answer",
  "method": "bm25_then_vector",
  "layers_tried": ["bm25", "vector"],
  "layers_succeeded": ["bm25", "vector"],
  "fallbacks_used": [],
  "time_constraint": "2026-01-28",
  "stop_reason": "max_results_reached",
  "results_per_layer": {
    "bm25": 5,
    "vector": 3
  },
  "execution_time_ms": 234,
  "confidence": 0.87
}

Displaying to Users

## Retrieval Report

Method: Hybrid tier (BM25 + Vector reranking)
Layers: bm25 (5 results), vector (3 results)
Fallbacks: 0
Time filter: 2026-01-28
Execution: 234ms
Confidence: 0.87

Skill Contract

When implementing memory queries, follow this contract:

Required Steps

  1. Always check tier first:

    memory-daemon retrieval status
    
  2. Classify intent before routing:

    memory-daemon retrieval classify "<query>"
    
  3. Use tier-appropriate commands:

    • Tier 1-2: teleport hybrid
    • Tier 3: teleport vector
    • Tier 4: teleport search
    • Tier 5: query search
  4. Include explainability in response:

    • Report tier used
    • Report layers tried
    • Report fallbacks triggered

Validation Checklist

Before returning results:

  • Tier detection completed
  • Intent classified
  • Appropriate layers used for tier
  • Fallbacks handled gracefully
  • Explainability payload included
  • Stop conditions respected

Configuration

Retrieval policy is configured in ~/.config/agent-memory/config.toml:

[retrieval]
default_timeout_ms = 5000
default_max_nodes = 50
default_max_depth = 3
parallel_fan_out = 3

[retrieval.intent_defaults]
explore_beam_width = 5
answer_beam_width = 3
locate_early_stop = true
timeboxed_max_depth = 2

[retrieval.fallback]
enabled = true
max_fallback_attempts = 3
fallback_timeout_factor = 0.5

Error Handling

ErrorResolution
All layers failedReturn Tier 5 (Agentic) results
Timeout exceededReturn partial results with explanation
No results foundBroaden query or suggest alternatives
Intent unclearDefault to Answer intent

Integration with Ranking

Results are ranked using Phase 16 signals:

SignalWeightDescription
Salience score0.3Memory importance (Procedure > Observation)
Recency0.3Time-decayed scoring
Relevance0.3BM25/Vector match score
Usage0.1Access frequency (if enabled)

See Command Reference for full CLI options.

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

78/100Analyzed 2/19/2026

Highly comprehensive and well-structured skill covering intelligent memory retrieval policies. Excellent actionability with clear commands, tables, and skill contract. Well-organized with When to Use/When Not to Use sections, capability tiers, intent classification, and fallback chains. However, deep nesting in .opencode path and project-specific commands (memory-daemon) indicate internal-only use. The conceptual framework is solid but tied to a specific internal system.

95
90
70
90
88

Metadata

Licenseunknown
Version-
Updated2/13/2026
PublisherSpillwaveSolutions

Tags

No tags yet.