Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

fix: Broken Omit attrbutes in OpenAI Agents sdk (#1090)

Ishan Jainc180c098e843
diff --git a/sdk/python/src/openlit/_instrumentors.py b/sdk/python/src/openlit/_instrumentors.py
index 6bb25dec..a2564448 100644
--- a/sdk/python/src/openlit/_instrumentors.py
+++ b/sdk/python/src/openlit/_instrumentors.py
@@ -173,7 +173,7 @@ def get_instrumentor_class(name):
try:
module = importlib.import_module(module_path)
return getattr(module, class_name)
- except (ImportError, AttributeError):
+ except Exception:
return None
diff --git a/sdk/python/src/openlit/instrumentation/openai/utils.py b/sdk/python/src/openlit/instrumentation/openai/utils.py
index ff37f8ef..6aab926a 100644
--- a/sdk/python/src/openlit/instrumentation/openai/utils.py
+++ b/sdk/python/src/openlit/instrumentation/openai/utils.py
@@ -33,9 +33,10 @@ logger = logging.getLogger(__name__)
def handle_not_given(value, default=None):
"""
- Handle OpenAI's NotGiven values and None values by converting them to appropriate defaults.
+ Handle OpenAI's NotGiven/Omit sentinel values and None by converting them to defaults.
+ The Responses API uses 'Omit' while the Chat Completions API uses 'NotGiven'.
"""
- if hasattr(value, "__class__") and value.__class__.__name__ == "NotGiven":
+ if hasattr(value, "__class__") and value.__class__.__name__ in ("NotGiven", "Omit"):
return default
if value is None:
return default
diff --git a/sdk/python/src/openlit/instrumentation/openai_agents/processor.py b/sdk/python/src/openlit/instrumentation/openai_agents/processor.py
index 5d02a084..6c536766 100644
--- a/sdk/python/src/openlit/instrumentation/openai_agents/processor.py
+++ b/sdk/python/src/openlit/instrumentation/openai_agents/processor.py
@@ -36,7 +36,7 @@ try:
if TYPE_CHECKING:
from agents import Trace, Span
TRACING_AVAILABLE = True
-except ImportError:
+except Exception:
class TracingProcessor:
"""Dummy TracingProcessor for when agents is not available."""