Skip to main content
POST
/
api
/
memories
/
context
Search by context
curl --request POST \
  --url https://api.example.com/api/memories/context \
  --header 'Content-Type: application/json' \
  --data '
{
  "context": {},
  "limit": 123,
  "min_similarity": 123,
  "agent_id": 123,
  "session_id": 123
}
'
This is the most powerful memory retrieval method. It answers: “What did we do last time we were in this exact situation?”

Request body

context
EventContext
required
Context to match against. See Types.
limit
integer
default:"10"
Maximum number of results.
min_similarity
number
default:"0.6"
Minimum similarity threshold (0.01.0). Set to null to use the default.
agent_id
integer
Filter by agent. Set to null to search across all agents.
session_id
integer
Filter by session. Set to null to search across all sessions.

Example request

{
  "context": {
    "active_goals": [
      {
        "id": 101,
        "description": "book_movie",
        "priority": 0.9,
        "progress": 0.5,
        "deadline": null,
        "subgoals": []
      }
    ],
    "environment": {
      "variables": { "user_id": "user_99" },
      "spatial": null,
      "temporal": {
        "time_of_day": null,
        "deadlines": [],
        "patterns": []
      }
    },
    "resources": {
      "computational": {
        "cpu_percent": 50.0,
        "memory_bytes": 1024000,
        "storage_bytes": 1024000000,
        "network_bandwidth": 1000
      },
      "external": {}
    },
    "fingerprint": 0,
    "embeddings": null
  },
  "limit": 5,
  "min_similarity": 0.8,
  "agent_id": null,
  "session_id": null
}

Response

Returns an array of MemoryResponse objects (same schema as Get agent memories).
The system uses a context fingerprint (a hash of the context) to find near-identical situations instantly. Always query by context and goal — this ensures your agent doesn’t get confused by history from a different task.