Skip to content

[BUG] Get Agentic Memory API can't work for KNN memory index #4141

@ylwu-amzn

Description

@ylwu-amzn

What is the bug?
See null pointer exception when run get agentic memory API for KNN memory index.

The issue is from this line https://github.com/opensearch-project/ml-commons/blob/3.2/common/src/main/java/org/opensearch/ml/common/memorycontainer/MLMemory.java#L207

memoryEmbedding = parser.map();

This doesn't work for text embedding.

How can one reproduce the bug?
Steps to reproduce the behavior:

  1. Follow this tutorial https://github.com/opensearch-project/ml-commons/blob/main/docs/tutorials/agentic_memory/agentic_memory_with_strands_agent.md, create embedding model and LLM
  2. Follow this doc https://docs.opensearch.org/latest/ml-commons-plugin/api/agentic-memory-apis/index/, create memory container and add memory
  3. Run get memory API GET /_plugins/_ml/memory_containers/{memory_container_id}/memories/{memory_id}
  4. See error
{
  "error": {
    "root_cause": [
      {
        "type": "null_pointer_exception",
        "reason": "Cannot invoke \"String.hashCode()\" because \"<local12>\" is null"
      }
    ],
    "type": "null_pointer_exception",
    "reason": "Cannot invoke \"String.hashCode()\" because \"<local12>\" is null"
  },
  "status": 500
}

What is the expected behavior?
Should return memory

What is your host/environment?

  • OS: Linux
  • Version 3.2
  • Plugins

Do you have any screenshots?
NO

Do you have any additional context?
Error log

[2025-08-28T07:07:57,389][WARN ][r.suppressed             ] [node4] path: /_plugins/_ml/memory_containers/FUFh75gB53PFBUPVz9uW/memories/iUGA75gB53PFBUPVH9ut, params: {memory_id=iUGA75gB53PFBUPVH9ut, memory_container_id=FUFh75gB53PFBUPVz9uW}
java.lang.NullPointerException: Cannot invoke "String.hashCode()" because "<local12>" is null
    at org.opensearch.ml.common.memorycontainer.MLMemory.parse(MLMemory.java:169) ~[opensearch-ml-common-3.2.0.0.jar:?]
    at org.opensearch.ml.action.memorycontainer.memory.TransportGetMemoryAction.processResponse(TransportGetMemoryAction.java:131) [opensearch-ml-3.2.0.0.jar:3.2.0.0]
    at org.opensearch.ml.action.memorycontainer.memory.TransportGetMemoryAction.lambda$doExecute$1(TransportGetMemoryAction.java:105) [opensearch-ml-3.2.0.0.jar:3.2.0.0]
    at org.opensearch.core.action.ActionListener$1.onResponse(ActionListener.java:82) [opensearch-core-3.2.0.jar:3.2.0]
    at org.opensearch.action.support.TransportAction$1.onResponse(TransportAction.java:115) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.action.support.TransportAction$1.onResponse(TransportAction.java:109) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction$2.handleResponse(TransportSingleShardAction.java:298) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction$2.handleResponse(TransportSingleShardAction.java:284) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.security.transport.SecurityInterceptor$RestoringTransportResponseHandler.handleResponse(SecurityInterceptor.java:422) [opensearch-security-3.2.0.0.jar:3.2.0.0]
    at org.opensearch.transport.TransportService$ContextRestoreResponseHandler.handleResponse(TransportService.java:1587) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.transport.NativeMessageHandler.doHandleResponse(NativeMessageHandler.java:468) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.transport.NativeMessageHandler.handleResponse(NativeMessageHandler.java:460) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.transport.NativeMessageHandler.handleMessage(NativeMessageHandler.java:197) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.transport.NativeMessageHandler.messageReceived(NativeMessageHandler.java:149) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.transport.InboundHandler.messageReceivedFromPipeline(InboundHandler.java:152) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.transport.InboundHandler.inboundMessage(InboundHandler.java:144) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.transport.TcpTransport.inboundMessage(TcpTransport.java:804) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.transport.InboundBytesHandler.forwardFragments(InboundBytesHandler.java:137) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.transport.InboundBytesHandler.doHandleBytes(InboundBytesHandler.java:77) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.transport.InboundPipeline.doHandleBytes(InboundPipeline.java:124) [opensearch-3.2.0.jar:3.2.0]
    at org.opensearch.transport.InboundPipeline.handleBytes(InboundPipeline.java:113) [opensearch-3.2.0.jar:3.2.0]

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions