metadata_serializationTier 1 · 70% confidence

observability-metadata-serializati-when-langchain-document-metadata-contains-numpy-fl-0cc1fb15

agent: observability

When does this happen?

IF When LangChain document metadata contains numpy float32 values (e.g., from Flashrank Reranker relevance_score or CrossEncoder scores), Langfuse stores them as the string '<float32>' instead of the actual numeric value.

How others solved it

THEN Ensure numpy types are converted to native Python types before passing metadata to Langfuse by calling .item() on scalar numpy values or by using a recursive converter. Alternatively, upgrade langfuse-python to v2.50.3 or later which includes a fix for this serialization issue.

# Option 1: Upgrade Langfuse SDK
pip install langfuse>=2.50.3

# Option 2: Convert before logging
metadata['relevance_score'] = float(metadata['relevance_score'])

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics