🐛 Bug Report: LiteLLM instrumentation does not record seed, stop, frequency_penalty, presence_penalty

Aperta Adatta ai principianti
#4,598 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@shantam77 ci sta già lavorando.

Dal 11/10/2026.

  • #4607 di @shantam77 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
ai, observability

Direzione di ricerca

Inizia da _set_request_attributes in opentelemetry/instrumentation/litellm/__init__.py e confronta il suo mapping degli attributi della richiesta con il callback di LiteLLM. Usa la riproduzione fornita per confermare quali attributi GenAI vengono emessi, quindi aggiungi il test per seed, stop, frequency_penalty e presence_penalty, preservando gli attributi esistenti. La fine significa che tutti e quattro i parametri compaiono con i nomi gen_ai.request.* specificati quando vengono forniti.

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

Descrizione

Which component is this bug for?

AlephAlpha Instrumentation

📜 Description

Package: opentelemetry-instrumentation-litellm 0.62.4 (not in the component list, so I picked the closest option).

_set_request_attributes in the LiteLLM instrumentation (opentelemetry/instrumentation/litellm/__init__.py, lines 166-178 at 0.62.4) records only gen_ai.request.model, temperature, top_p and max_tokens. Request parameters that the GenAI semantic conventions define and that LiteLLM forwards to the provider are dropped: gen_ai.request.seed, gen_ai.request.stop_sequences, gen_ai.request.frequency_penalty, gen_ai.request.presence_penalty. A trace therefore cannot show why two otherwise identical calls behaved differently.

For comparison, LiteLLM's own OpenTelemetry callback records all of them for the same call. Related: #4538 covers seed / stop_sequences in the OpenAI package; this is the separate LiteLLM package, which also misses the penalties.

👟 Reproduction steps

pip install litellm opentelemetry-instrumentation-litellm opentelemetry-sdk httpx

import os
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
import httpx, litellm, openai
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
from opentelemetry.instrumentation.litellm import LiteLLMInstrumentor

exporter = InMemorySpanExporter()
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(exporter))
LiteLLMInstrumentor().instrument(tracer_provider=provider)

client = openai.OpenAI(api_key="x", max_retries=0, http_client=httpx.Client(transport=httpx.MockTransport(
    lambda r: httpx.Response(200, json={"id": "c1", "object": "chat.completion", "created": 0, "model": "gpt-4o-mini",
        "choices": [{"index": 0, "message": {"role": "assistant", "content": "Hello"}, "finish_reason": "stop"}],
        "usage": {"prompt_tokens": 11, "completion_tokens": 5, "total_tokens": 16}}))))
litellm.completion(model="openai/gpt-4o-mini", messages=[{"role": "user", "content": "hi"}], client=client, api_key="x",
                   seed=7, stop=["END"], temperature=0.3, top_p=0.9, max_tokens=50,
                   frequency_penalty=0.1, presence_penalty=0.2)
print({k: v for k, v in exporter.get_finished_spans()[0].attributes.items() if k.startswith("gen_ai.request.")})
👍 Expected behavior

gen_ai.request.seed, gen_ai.request.stop_sequences, gen_ai.request.frequency_penalty and gen_ai.request.presence_penalty are set when the call passes them.

👎 Actual Behavior with Screenshots
gen_ai.request.model = openai/gpt-4o-mini
gen_ai.request.temperature = 0.3
gen_ai.request.top_p = 0.9
gen_ai.request.max_tokens = 50

(seed, stop, frequency_penalty and presence_penalty were sent but are not recorded)

🤖 Python Version

3.12

📃 Provide any additional context for the Bug.

opentelemetry-instrumentation-litellm 0.62.4 (the latest release), litellm 1.104.2.

👀 Have you spent some time to check if this bug has been raised before?
  • I checked and didn't find similar issue
Are you willing to submit PR?

None

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.