Remember a session memory Experimental

POST /api/context_engine/memory/_remember

Spaces method and path for this operation:

post /s/{space_id}/api/context_engine/memory/_remember

Refer to Spaces for more information.

Writes one memory to the session memory store. Pass id to revise an existing memory. The revision replaces the memory in full.

Returns 202 with the memory id and writes the memory in the background, because semantic indexing runs inside the write. The memory becomes searchable after the background write completes.

Requires the contextEngine:write privilege. Without user_id, the route writes the memory for the caller's user profile, and a caller without a user profile gets a 403. Naming another user in user_id also requires contextEngine:manage_memory.

Each AI index in ai_index_ids must exist in this space, and the caller requires the Elasticsearch write privilege on its backing index. Otherwise, the route rejects the request and writes nothing.

After authorization, validation, and feature-flag checks pass, the route writes one memory_remember audit event per request, when the background write finishes or when it rejects the request. The route does not report a failed background write in the response. Instead, it logs the error to the Kibana logs and writes a failure audit event.

Returns a 404 response when Context Engine is turned off in this space (contextEngine:enabled), when memory is turned off (contextEngine:memoryEnabled), or when an AI index in ai_index_ids does not exist.

For more information, refer to the Context Engine documentation.

[Required authorization] Route required privileges: contextEngine:write. Extended privileges (optional, expand functionality when granted): contextEngine:manage_memory.

Headers

  • kbn-xsrf string Required

    A required header to protect against CSRF attacks

application/json

Body

  • ai_index_ids array[string]

    The AI indices that dreaming promotes the memory into. Each must exist in this space, and the caller requires the Elasticsearch write privilege on its backing index.

    Not more than 100 elements. Minimum length of each is 1, maximum length of each is 256.

  • attributes object

    String hints about the memory for dreaming. Accepts up to 50 entries, with non-blank keys of 1 to 256 characters.

    Hide attributes attribute Show attributes attribute object
    • * string Additional properties

      Maximum length is 1024.

  • content string Required

    The memory text. Elasticsearch indexes this field for semantic search.

    Minimum length is 1, maximum length is 65536.

  • id string

    The id of an existing memory to revise. The revision replaces the memory in full, and the route does not check whether the id exists. Omit this field to generate a new id.

    Minimum length is 1, maximum length is 256.

  • session_id string Required

    The session the memory comes from.

    Minimum length is 1, maximum length is 256.

  • user_id string

    The Kibana user profile UID that the memory belongs to. Omit this field to use the caller's user profile. Naming another user requires contextEngine:manage_memory.

    Minimum length is 1, maximum length is 1024.

Responses

  • 202 application/json

    The route accepted the memory and is writing it in the background. It becomes searchable after the write completes.

    Hide response attribute Show response attribute object
    • id string Required

      The id of the memory. Pass it as id to revise the memory.

  • 403 application/json

    user_id is missing and the caller has no user profile, user_id names another user and the caller lacks contextEngine:manage_memory, or the caller cannot write to one of the AI indices.

    Hide response attributes Show response attributes object
    • error string

      The HTTP status text.

    • message string Required

      A human-readable error message.

    • statusCode number

      The HTTP status code.

  • 404 application/json

    Context Engine or memory is turned off, or an AI index does not exist.

    Hide response attributes Show response attributes object
    • error string

      The HTTP status text.

    • message string Required

      A human-readable error message.

    • statusCode number

      The HTTP status code.

POST /api/context_engine/memory/_remember
curl \
  -X POST "https://${KIBANA_URL}/api/context_engine/memory/_remember" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -H "kbn-xsrf: true" \
  -d '{
    "session_id": "8f3c2a1e",
    "ai_index_ids": ["ops-memory"],
    "content": "checkout-service latency alert fired. Root cause is a connection pool limit after the 3.2 deploy.",
    "attributes": { "incident": "INC-4211" }
  }'
POST kbn:/api/context_engine/memory/_remember
{
  "session_id": "8f3c2a1e",
  "ai_index_ids": ["ops-memory"],
  "content": "checkout-service latency alert fired. Root cause is a connection pool limit after the 3.2 deploy.",
  "attributes": { "incident": "INC-4211" }
}
Request examples
Example request that stores a session memory for the caller and targets an AI index for dreaming
{
  "ai_index_ids": [
    "ops-memory"
  ],
  "attributes": {
    "incident": "INC-4211"
  },
  "content": "checkout-service latency alert fired. Root cause is a connection pool limit after the 3.2 deploy.",
  "session_id": "8f3c2a1e"
}
Example request that replaces an existing session memory by passing its `id`
{
  "ai_index_ids": [
    "ops-memory"
  ],
  "attributes": {
    "incident": "INC-4211"
  },
  "content": "checkout-service latency alert fired. Root cause is a connection pool limit after the 3.2 deploy; mitigated by raising max_connections to 200.",
  "id": "7c1f0b2e-5a43-4b0e-9a57-2f0f6f1d3a10",
  "session_id": "8f3c2a1e"
}
Response examples (202)
The route accepted the memory and is writing it in the background. It becomes searchable after the write completes
{
  "id": "7c1f0b2e-5a43-4b0e-9a57-2f0f6f1d3a10"
}
Response examples (403)
The caller lacks the Elasticsearch `write` privilege on an AI index's backing index
{
  "error": "Forbidden",
  "message": "AI index 'ops-memory' is not writable. Writing to it needs the Elasticsearch 'write' privilege on its backing index.",
  "statusCode": 403
}
`user_id` names another user and the caller lacks `contextEngine:manage_memory`
{
  "error": "Forbidden",
  "message": "Acting on the memory of another user requires the [contextEngine:manage_memory] privilege.",
  "statusCode": 403
}
`user_id` is missing and the caller has no user profile
{
  "error": "Forbidden",
  "message": "The caller has no user profile, so the request cannot be attributed to a user. Log in to Kibana once to create a profile, use an API key whose owner has one, or set `user_id` if you have the `contextEngine:manage_memory` privilege.",
  "statusCode": 403
}
Response examples (404)
An AI index in `ai_index_ids` does not exist in this space
{
  "error": "Not Found",
  "message": "AI index 'ops-memory' not found",
  "statusCode": 404
}
Context Engine is turned off in this space
{
  "error": "Not Found",
  "message": "Not Found",
  "statusCode": 404
}
Context Engine memory is turned off
{
  "error": "Not Found",
  "message": "Context Engine memory is turned off.",
  "statusCode": 404
}