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分
- マージ済み PR(30日)
- 38
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
langfuse/langfuse-python のほかの issue
-
bug feat-prompt-management sdk-python
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
langfuse/langfuse-python#1976 ·
メンテナーはふだん 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 日以内に返信
-
bug: GCS upload detection in MediaManager uses substring match on the full URL対応中かも @hassiebp が 10 日前に担当しました。 オープンbug feat-multimodal-media sdk-python
langfuse/langfuse-python#1913 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
langfuse/langfuse-python の issue をすべて見る
似ている issue
-
namespace operations
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
EclipseFdn/open-vsx.org#14043 ·
メンテナーはふだん 1 日以内に返信
-
netbox status: needs triage type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
netbox-community/netbox#23376 ·
メンテナーはふだん 1 日以内に返信
-
feedback simulation workshop
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
githubnext/gh-aw-workshop#4455 ·
メンテナーはふだん 1 日以内に返信
-
Triage 🩺
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_waitオープンneeds-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
krkn-chaos/krkn#1627 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信