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

オープン 初心者向け
#4,598 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@shantam77 がすでに取り組んでいます。

2026年10月11日 から。

  • #4607 @shantam77 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
ai, observability

調査の方向性

opentelemetry/instrumentation/litellm/__init__.py の _set_request_attributes から始め、そのリクエスト属性のマッピングを LiteLLM コールバックと比較する。提供された再現手順を使用して、どの GenAI 属性が出力されるかを確認し、既存の属性を保持したまま、seed、stop、frequency_penalty、presence_penalty のカバレッジを追加する。完了とは、指定された4つのパラメータが渡されたときに、指定された gen_ai.request.* の名前で出力されることを意味する。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Python
スター
7.5k
フォーク
1.2k
平均マージ
2日 6時間
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

traceloop/openllmetry のほかの issue

traceloop/openllmetry の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。