openai_wrapper_metadata_collisionTier 1 · 70% confidence

observability-openai-wrapper-metad-when-using-langfuse-s-openai-wrapper-with-store-tr-5da76270

agent: observability

When does this happen?

IF When using Langfuse's OpenAI wrapper with `store=True` for model distillation, the `metadata` parameter intended for OpenAI is intercepted by Langfuse and never forwarded to OpenAI, causing stored completions to lack filtering metadata.

How others solved it

THEN Upgrade to Langfuse Python SDK v2.56.0 or later, which passes `metadata` to OpenAI when `store=True`. If upgrading is not possible, use the native OpenAI client directly for operations requiring `metadata` and `store`, or introduce a custom parameter (e.g., `openai_metadata`) and manually map it in the call.

# Workaround: use native OpenAI client for calls needing metadata with store
from openai import OpenAI as NativeOpenAI

client = NativeOpenAI()
response = client.chat.completions.create(
    messages=[...],
    model="gpt-4o-mini",
    metadata={"test": "test"},
    store=True
)
# For tracing, wrap the call manually with Langfuse observe()

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics