Skip to main content

Search Endpoint

The search endpoint provides semantic search across all memory types using vector similarity.

Search Memories

Perform semantic search across an agent’s memories.
POST /search

Headers

Authorization: Bearer sk-your-api-key
Content-Type: application/json

Request Body

{
  "agent_id": "claire",
  "query": "performance optimization techniques",
  "limit": 10,
  "types": ["episodes", "beliefs", "notes"],
  "min_score": 0.5
}
FieldTypeDefaultDescription
agent_idstringRequiredAgent identifier
querystringRequiredSearch query text
limitinteger10Maximum results to return
typesarrayallMemory types to search
min_scorefloat0.0Minimum similarity score (0-1)

Response

{
  "success": true,
  "data": {
    "results": [
      {
        "type": "episode",
        "id": "ep_abc123",
        "score": 0.92,
        "content": {
          "objective": "Optimized database queries",
          "outcome": "Reduced latency by 60%",
          "lessons": ["Index frequently queried columns"]
        },
        "created_at": "2024-01-10T15:30:00Z"
      },
      {
        "type": "belief",
        "id": "bel_def456",
        "score": 0.87,
        "content": {
          "statement": "Premature optimization is the root of all evil",
          "confidence": 0.75
        },
        "created_at": "2024-01-05T10:00:00Z"
      },
      {
        "type": "note",
        "id": "note_ghi789",
        "score": 0.81,
        "content": {
          "content": "Caching reduces database load significantly",
          "note_type": "insight"
        },
        "created_at": "2024-01-12T09:15:00Z"
      }
    ],
    "total": 3,
    "query_time_ms": 45
  }
}

CLI Equivalent

kernle -a claire search "performance optimization techniques" --limit 10

Searchable Memory Types

TypeWhat’s Indexed
episodesObjective, outcome, lessons
beliefsStatement
notesContent
agent_valuesName, statement
goalsTitle, description
playbooksName, description, steps
raw_entriesContent
relationshipsEntity name, notes

Search Modes

Hybrid Search (Default)

Combines vector similarity with keyword matching for best results:
{
  "agent_id": "claire",
  "query": "API rate limiting",
  "mode": "hybrid"
}

Vector Only

Pure semantic similarity search:
{
  "agent_id": "claire",
  "query": "API rate limiting",
  "mode": "vector"
}

Keyword Only

Traditional text search:
{
  "agent_id": "claire",
  "query": "API rate limiting",
  "mode": "keyword"
}

By Memory Type

{
  "agent_id": "claire",
  "query": "debugging techniques",
  "types": ["episodes"]
}

By Time Range

{
  "agent_id": "claire",
  "query": "debugging",
  "created_after": "2024-01-01T00:00:00Z",
  "created_before": "2024-01-31T23:59:59Z"
}

By Tags

{
  "agent_id": "claire",
  "query": "debugging",
  "tags": ["production", "urgent"]
}

Search Quality

Search quality depends on:
  1. Embedding model: Kernle uses modern embedding models for semantic understanding
  2. Memory quality: Well-written lessons and descriptions improve search
  3. Query clarity: Specific queries return better results than vague ones
For best results, write clear, descriptive content when recording memories. “Fixed the bug” is less searchable than “Resolved race condition in async queue handler”.

FeatureLocalCloud
Speed~10ms~50-100ms
QualityText matchingVector similarity
Offline
Cross-device
The CLI automatically uses cloud search when configured, with fallback to local:
# Uses cloud if available, local otherwise
kernle -a claire search "query"