🐛 Bug Report: OpenAI instrumentation drops gen_ai.input.messages on image requests when no uploader is configured

Aperta
#4,690 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Tyagiquamar ci sta già lavorando.

Dal 4/11/2026.

  • #4692 di @Tyagiquamar — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Start with openai/__init__.py:20-22 and shared/chat_wrappers.py:441,448; trace how the default uploader is checked and awaited, then inspect the existing tests for base64 image chat messages. Confirm that requests without an uploader still set gen_ai.input.messages with the image inline, and check the other instrumentor defaults mentioned in the issue. An open pull request already addresses this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug python
Which component is this bug for?

OpenAI Instrumentation

📜 Description

The default upload_base64_image in OpenAIInstrumentor.__init__ is a sync lambda, lambda *args: "" (openai/__init__.py:20-22), but it is awaited in shared/chat_wrappers.py:441:

url = await Config.upload_base64_image(str(trace_id), str(span_id), image_name, base64_string)

Because the default is truthy, _set_prompts always goes into the image path (chat_wrappers.py:448). That raises TypeError: object str can't be used in 'await' expression, @dont_throw swallows it, and _set_input_messages never runs. So gen_ai.input.messages is missing on every chat request that contains a base64 image.

This hits anyone using the instrumentation without Traceloop.init() (zero-code opentelemetry-instrument, or OpenAIInstrumentor().instrument() directly), since only the SDK passes an async uploader.

👟 Reproduction steps
  1. OpenAIInstrumentor().instrument() on a plain TracerProvider (no traceloop-sdk)
  2. Call client.chat.completions.create(...) with a message that has an image_url part with a data:image/png;base64,... URL
👍 Expected behavior

gen_ai.input.messages is set, with the image kept inline (or as a URI if an uploader is configured).

👎 Actual Behavior with Screenshots

The span has gen_ai.output.messages but no gen_ai.input.messages.

🤖 Python Version

3.12

📃 Provide any additional context for the Bug.

Workaround: OpenAIInstrumentor(upload_base64_image=None).instrument(). With None the image is kept inline as a blob part. Suggested fix: default to None, or make the default an async def. Also worth checking the anthropic, google-generativeai and vertexai defaults (None): anthropic then writes the raw base64 into span attributes (anthropic/span_utils.py:39-45), which can be very large.

Lingua principale
Python
Stelle
7.5k
Fork
1.2k
Merge medio
2g 6h
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di traceloop/openllmetry

Tutte le issue di traceloop/openllmetry

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.