Repository navigation
Conversation
When using OpenAI Agents SDK, an Omit sentinel can be sent, resulting in raising the "metadata must be a dictionary" error
|
|
|
@druce Thanks a lot for your contribution! Did you check when |
|
line 328 here is where openai sends an Omit object - https://github.com/openai/openai-agents-python/blob/main/src/agents/models/openai_responses.py to replicate: |
|
inadvertently clicked 'close with comment!' |
I think it was here? |
When using OpenAI Agents SDK, an Omit sentinel can be sent, resulting in raising the "metadata must be a dictionary" error
Important
Adds handling for
Omittype in metadata validation inopenai.pyto prevent TypeError with OpenAI Agents SDK.Omittype in metadata validation in_get_langfuse_data_from_kwargs()inopenai.py.Omitsentinel.Omitfromopenai._types.NotGivenhandling pattern.This description was created by
for 7cc621e. You can customize this summary. It will automatically update as commits are pushed.
Disclaimer: Experimental PR review
Greptile Overview
Updated On: 2025-11-03 18:01:51 UTC
Greptile Summary
Adds handling for OpenAI's
Omitsentinel type in metadata validation to prevent TypeError when using the OpenAI Agents SDK.Key changes:
Omittype fromopenai._typesalongside existingNotGivenimportisinstance(metadata, Omit)check in_get_langfuse_data_from_kwargsfunction at langfuse/openai.py:401Context:
This mirrors a previous fix (commit 9c6a71d) that added
NotGivenhandling. The OpenAI Agents SDK can sendOmitsentinel values for optional parameters, which was causing the "metadata must be a dictionary" validation error to be raised incorrectly. The fix follows the established pattern and allowsOmitvalues to pass through validation just likeNotGivenvalues.Confidence Score: 4/5
Omittype handling to match the existingNotGivenpattern. It directly addresses the reported issue without introducing new logic. Score of 4 (not 5) due to lack of test coverage for the newOmithandling, though the change follows the established pattern.Important Files Changed
File Analysis
Omittype handling to metadata validation, mirroring existingNotGivencheck to prevent TypeError when OpenAI Agents SDK passes Omit sentinelSequence Diagram
sequenceDiagram participant AgentsSDK as OpenAI Agents SDK participant LangfuseOpenAI as langfuse.openai participant Validator as _get_langfuse_data_from_kwargs participant Client as Langfuse Client AgentsSDK->>LangfuseOpenAI: API call with metadata=Omit LangfuseOpenAI->>Validator: Extract kwargs Validator->>Validator: Check metadata type alt metadata is Omit Validator->>Validator: Skip validation (Omit sentinel) else metadata is NotGiven Validator->>Validator: Skip validation (NotGiven sentinel) else metadata is dict Validator->>Validator: Validation passes else metadata is other type Validator-->>LangfuseOpenAI: Raise TypeError end Validator->>Client: Pass validated metadata Client->>Client: Process trace/observation