bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder item
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
Describe the bug
In ChatPromptClient.compile, when a placeholder value is a list and an element is not a dict, the code appends ChatMessageDict(role="NOT_GIVEN", content=str(placeholder_value)). This is the inner else of the per-item loop, at langfuse/model.py line 365 (lines 362-368).
placeholder_value is the whole list, not the current item. N non-dict items therefore produce N identical messages, each containing the full list, and no message contains its own element. The input is already invalid (the warning says "Appended as string"), but the output is duplicated, garbled content.
I would expect one message per item, for example with content=str(msg), though maintainers may prefer a different handling of invalid items (skipping them, raising, etc.). The point is that the current output repeats the whole list per item.
Steps to reproduce
from langfuse.model import ChatPromptClient
from langfuse.api import Prompt_Chat
c = ChatPromptClient(Prompt_Chat(name="p", version=1, type="chat", config={}, labels=[], tags=[], commit_message=None,
prompt=[{"type": "chatmessage", "role": "system", "content": "hi {{x}}"}, {"type": "placeholder", "name": "history"}]))
print(c.compile(x="1", history=["a", "b"]))
Observed:
[{'role': 'system', 'content': 'hi 1'}, {'role': 'NOT_GIVEN', 'content': "['a', 'b']"}, {'role': 'NOT_GIVEN', 'content': "['a', 'b']"}]
The last two messages each contain the whole list ['a', 'b'] instead of 'a' and 'b' respectively.
Langfuse Cloud or self-hosted?
Langfuse Cloud (not server dependent; the behavior is purely client-side in the SDK)
If self-hosted, what version are you running?
N/A
SDK and integration versions
langfuse 4.17.0 (main at bf11ec121479145923ff27b32ec2ad1d06fd2d51), Python 3.14.0
Additional information
Related open PR #1840 (LangChain message objects in placeholders) touches the same loop; as far as its diff shows it keeps the str(placeholder_value) fallback for other non-dict items.
Are you interested in contributing a fix for this bug?
No
- 主要语言
- Python
- 星标
- 498
- 派生
- 361
- 平均合并
- 16 小时 40 分钟
- 30 天内合并 PR
- 38
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
langfuse/langfuse-python 的其他 Issue
-
tests/unit/test_prompt.py fails on a fresh clone without LANGFUSE_* env vars可能已有人在做 @Mathoholic 今天认领。 未关闭bug feat-prompt-management sdk-python
难度 2/5 1-3 小时 新手友好度 80/100
langfuse/langfuse-python#1976 · 3 条评论 ·
维护者通常 1 天内回复
-
bug(langchain): failed streaming LLM runs retain IDs in callback memo可能已有人在做 @hassiebp 今天认领。 未关闭bug integration-langchain sdk-python
langfuse/langfuse-python#1977 · 已指派 1 人 ·
维护者通常 1 天内回复
-
bug: LANGFUSE_MAX_EVENT_SIZE_BYTES is parsed but never enforced for score events可能已有人在做 @hassiebp 于 2 天前认领。 未关闭bug feat-scores sdk-python
langfuse/langfuse-python#1966 · 已指派 1 人 ·
维护者通常 1 天内回复
-
bug: non-numeric status in a 207 error entry raises inside handle_exception, kills the score consumer thread, flush()/shutdown() then hang可能已有人在做 @hassiebp 于 2 天前认领。 未关闭[Integrations] Language Clients bug feat-scores sdk-python
langfuse/langfuse-python#1967 · 已指派 1 人 ·
维护者通常 1 天内回复
-
bug: Partial-failure (207) ingestion response retries the whole batch up to 3x; per-item error details only logged at DEBUG可能已有人在做 @hassiebp 于 2 天前认领。 未关闭bug feat-ingestion
langfuse/langfuse-python#1965 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 langfuse/langfuse-python 的全部 Issue
相似的 Issue
-
needs triage
难度 2/5 1-3 小时 新手友好度 83/100
darnitdevorg/darnit#587 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
accessibility good first issue
难度 1/5 1-3 小时 新手友好度 92/100
维护者通常 1 天内回复
-
llm translation
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug bug-hunt
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复