bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder item
Les mainteneurs répondent en général sous 1 jour
Évaluation
Cette issue n'a pas encore été évaluée.
Description
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
- Langage dominant
- Python
- Étoiles
- 498
- Forks
- 361
- Merge moyen
- 16 h 42 min
- PR mergées (30 j)
- 51
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de langfuse/langfuse-python
-
tests/unit/test_prompt.py fails on a fresh clone without LANGFUSE_* env varsPeut-être pris @Mathoholic l’a pris il y a 3 jours. Ouvertebug feat-prompt-management sdk-python
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
langfuse/langfuse-python#1976 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
bug(langchain): failed streaming LLM runs retain IDs in callback memoPeut-être pris @hassiebp l’a pris il y a 3 jours. Ouvertebug integration-langchain sdk-python
langfuse/langfuse-python#1977 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
bug: LANGFUSE_MAX_EVENT_SIZE_BYTES is parsed but never enforced for score eventsPeut-être pris @hassiebp l’a pris il y a 5 jours. Ouvertebug feat-scores sdk-python
langfuse/langfuse-python#1966 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
bug: non-numeric status in a 207 error entry raises inside handle_exception, kills the score consumer thread, flush()/shutdown() then hangPeut-être pris @hassiebp l’a pris il y a 5 jours. Ouverte[Integrations] Language Clients bug feat-scores sdk-python
langfuse/langfuse-python#1967 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
bug: Partial-failure (207) ingestion response retries the whole batch up to 3x; per-item error details only logged at DEBUGPeut-être pris @hassiebp l’a pris il y a 5 jours. Ouvertebug feat-ingestion
langfuse/langfuse-python#1965 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de langfuse/langfuse-python
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
-
[Bug]: Importing weave changes the process-wide localePeut-être pris @himanshu748 l’a pris aujourd’hui. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
-
UX
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
mediajunkie/piper-morgan-product#2008 · 2 commentaires ·