Description
weave.integrations.openai.openai_sdk.should_use_accumulator crashes (and the crash is swallowed by the op wrapper) when a streaming call is made with an explicit extra_headers=None. extra_headers is typed Headers | None, so None is a valid value. When it's passed, the accumulator check raises AttributeError, the exception is caught silently, and the streaming response is not accumulated — the trace stores the raw un-consumed iterator instead of the assembled content/usage. Silent observability loss with no error surfaced to the user.
weave version: 0.53.5.dev0 (master @ 1213bfa) · python 3.13 · openai 2.30.0
Reproducer
from weave.integrations.openai.openai_sdk import should_use_accumulator
# extra_headers: Headers | None -> None is valid and reaches here
should_use_accumulator({"stream": True, "extra_headers": None})
# AttributeError: 'NoneType' object has no attribute 'get'
Equivalent end-user trigger:
client.chat.completions.create(model="gpt-4o", messages=[...], stream=True, extra_headers=None)
Root cause
weave/integrations/openai/openai_sdk.py:374
and not inputs.get("extra_headers", {}).get("X-Stainless-Raw-Response") == "true"
The {} default only applies when the key is absent; an explicit None value passes through, so None.get(...) raises.
Fix
(inputs.get("extra_headers") or {}).get(...). Happy to open a PR (branch ready, test included).
Description
weave.integrations.openai.openai_sdk.should_use_accumulatorcrashes (and the crash is swallowed by the op wrapper) when a streaming call is made with an explicitextra_headers=None.extra_headersis typedHeaders | None, soNoneis a valid value. When it's passed, the accumulator check raisesAttributeError, the exception is caught silently, and the streaming response is not accumulated — the trace stores the raw un-consumed iterator instead of the assembledcontent/usage. Silent observability loss with no error surfaced to the user.weave version: 0.53.5.dev0 (master @ 1213bfa) · python 3.13 · openai 2.30.0
Reproducer
Equivalent end-user trigger:
Root cause
weave/integrations/openai/openai_sdk.py:374The
{}default only applies when the key is absent; an explicitNonevalue passes through, soNone.get(...)raises.Fix
(inputs.get("extra_headers") or {}).get(...). Happy to open a PR (branch ready, test included).