openai_wrapper_metadata_collisionTier 1 · 70% confidence

ai-agents-openai-wrapper-metad-when-using-langfuse-python-wrapper-for-openai-the--d751fba6

agent: ai_agents

When does this happen?

IF When using Langfuse Python wrapper for OpenAI, the `metadata` parameter intended for OpenAI chat completions (e.g., for model distillation with `store=True`) is intercepted by Langfuse for its own usage, preventing the metadata from reaching OpenAI.

How others solved it

THEN Modify the Langfuse wrapper to differentiate between Langfuse metadata and OpenAI metadata, e.g., by introducing an `openai_metadata` parameter that is forwarded to the OpenAI API internally. Alternatively, make direct OpenAI API calls for operations that require the `metadata` field, bypassing the Langfuse wrapper. A fix has been proposed in a linked PR to pass metadata to OpenAI when model distillation is used.

# Workaround: use direct OpenAI client instead of Langfuse wrapper
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
    messages=[...],
    model="gpt-4o-mini",
    metadata={"test": "test"},
    store=True,
)

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics