Skip to content

fix: Postgres reorganizer fails when pgvector embedding is returned as string #2270

Description

@Kwizii

Bug Description

When MOS_ENABLE_REORGANIZE=true and GRAPH_DB_BACKEND=postgres, the reorganizer consumer crashes while preprocessing add messages:

pydantic_core.ValidationError: 1 validation error for GraphDBNode
metadata.embedding
  Input should be a valid list [type=list_type, input_value='[-0.047..., ...]', input_type=str]

PostgresGraphDB.get_node(..., include_embedding=True) assigns the pgvector column directly into metadata["embedding"]. With psycopg2, that value is often a JSON string rather than list[float], so GraphDBNode(**raw_node) fails and reorganize never runs.

How to Reproduce

  1. Run MemOS Product API with Postgres graph backend and MOS_ENABLE_REORGANIZE=true.
  2. Add a memory via /product/add.
  3. Observe reorganizer logs in _run_message_consumer_loop / _convert_id_to_node.

Environment

  • Python: 3.11
  • Operating System: Linux (Docker)
  • MemOS: main branch
  • Graph backend: postgres + pgvector

Additional Context

  • I am willing to implement this myself and have a patch ready on fork branch fix/postgres-embedding-normalize.

Metadata

Metadata

Labels

ai:failedAI task failed | AI 任务失败area:databasegraph_db + vector_db | 图数据库与向量数据库status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理types:bugSomething isn't working | 功能异常

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions