Skip to content

Recall API

Semantic search over agent memory — find past events, sessions, and lessons by meaning.

GET /api/recall

Perform a semantic search using natural language queries. Results are ranked by cosine similarity against stored embeddings.

Query Parameters

ParameterTypeDefaultDescription
querystring(required)Natural language search query
scopestringallSearch scope: all, events, sessions, lessons
agentIdstringFilter by agent ID
fromstringStart of time range (ISO 8601)
tostringEnd of time range (ISO 8601)
limitnumber10Maximum results to return (max: 100)
minScorenumber0Minimum cosine similarity score (0–1)

Response (200)

json
{
  "results": [
    {
      "sourceType": "event",
      "sourceId": "01HXYZ...",
      "score": 0.92,
      "text": "Tool call: search_database with query 'user authentication'",
      "metadata": {
        "sessionId": "ses_abc123",
        "eventType": "tool_call",
        "agentId": "my-agent"
      }
    },
    {
      "sourceType": "lesson",
      "sourceId": "lesson_456",
      "score": 0.87,
      "text": "Always validate JWT tokens before processing requests",
      "metadata": {
        "category": "security",
        "importance": "high"
      }
    }
  ],
  "query": "authentication errors",
  "totalResults": 2
}

Response Fields

FieldTypeDescription
resultsarrayMatching results, sorted by score descending
results[].sourceTypestringType of source: event, session, or lesson
results[].sourceIdstringID of the source record
results[].scorenumberCosine similarity score (0–1)
results[].textstringText content of the match
results[].metadataobjectAdditional metadata about the source
querystringThe original query string
totalResultsnumberTotal results found (before limit)

Errors

StatusCause
400Missing query parameter
401Invalid or missing API key
500Embedding backend error

curl Examples

bash
# Basic search
curl "http://localhost:3400/api/recall?query=authentication%20errors" \
  -H "Authorization: Bearer als_your_key"

# Scoped search with date range
curl "http://localhost:3400/api/recall?query=deployment%20failures&scope=events&limit=20&from=2026-01-01T00:00:00Z&to=2026-02-01T00:00:00Z" \
  -H "Authorization: Bearer als_your_key"

# High-confidence matches only
curl "http://localhost:3400/api/recall?query=rate%20limiting&minScore=0.8" \
  -H "Authorization: Bearer als_your_key"

CLI Usage

bash
agentlens recall "authentication errors"
agentlens recall "deployment failures" --scope events --limit 20
agentlens recall "user onboarding" --from 2026-01-01 --to 2026-02-01
agentlens recall "auth" --json

SDK Example

typescript
import { AgentLensClient } from '@agentlensai/sdk';

const client = new AgentLensClient({
  url: 'http://localhost:3400',
  apiKey: 'als_your_key',
});

const result = await client.recall({
  query: 'authentication errors',
  scope: 'events',
  limit: 10,
  minScore: 0.5,
});

for (const r of result.results) {
  console.log(`[${r.sourceType}] ${(r.score * 100).toFixed(1)}% — ${r.text}`);
}

Released under the MIT License.