🐛 Bug Report: LiteLLM instrumentation does not record seed, stop, frequency_penalty, presence_penalty
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 85/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
- 领域
- ai, observability
调研方向
从 opentelemetry/instrumentation/litellm/__init__.py 中的 _set_request_attributes 开始,将其请求属性映射与 LiteLLM callback 进行比较。使用提供的复现来确认发出了哪些 GenAI 属性,然后在保留现有属性的同时,为 seed、stop、frequency_penalty 和 presence_penalty 添加测试覆盖。完成的标准是,当提供这四个参数时,它们都使用指定的 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 小时
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
traceloop/openllmetry 的其他 Issue
-
bug python
难度 2/5 1-3 小时 新手友好度 76/100
traceloop/openllmetry#4717 ·
维护者通常 1 天内回复
-
🐛 Bug Report: Incomplete cache token migration after #4243 breaks Bedrock and Groq instrumentation可能已有人在做 @Quantum-Enigma-dot 于 21 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
traceloop/openllmetry#4665 · 1 条评论 ·
维护者通常 1 天内回复
-
🐛 Bug Report: OpenAI instrumentation drops gen_ai.usage.reasoning_tokens on streamed chat completions可能已有人在做 @jayfeng7 于 23 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
traceloop/openllmetry#4660 · 1 条评论 ·
维护者通常 1 天内回复
-
Bug Report: Failed dataset deletes still remove local rows and columns可能已有人在做 @inchang-ing 于 32 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
traceloop/openllmetry#4630 ·
维护者通常 1 天内回复
-
🐛 Bug Report: LiteLLM instrumentation never ends the span when a call is interrupted (KeyboardInterrupt, asyncio cancellation)可能已有人在做 @rupak-eng 于 39 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 80/100
traceloop/openllmetry#4597 · 1 条评论 ·
维护者通常 1 天内回复
查看 traceloop/openllmetry 的全部 Issue
相似的 Issue
-
Internal Error未关闭bug
难度 2/5 1-3 小时 新手友好度 66/100
frappe/frappe_docker#2071 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
The-Pocket/PocketFlow#161 ·
-
comp/desktop P2 type/bug
难度 2/5 1-3 小时 新手友好度 78/100
NousResearch/hermes-agent#157702 ·
维护者通常 1 天内回复
-
scibench_physics / scibench_chemistry: a correct answer scores 0 when the unit has a power of ten可能已有人在做 @BahaaMattar 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
EvolvingLMMs-Lab/lmms-eval#1699 ·
维护者通常 1 天内回复
-
project_inputs.html uses undefined file variable for dropdown IDs, lacks visual tag badges, and has empty delete labels可能已有人在做 @Rucha0901 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
aboutcode-org/scancode.io#2354 ·
维护者通常 1 天内回复