bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder item
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 498
- Forks
- 361
- Merge medio
- 16 h 40 min
- PR fusionados (30 d)
- 38
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de langfuse/langfuse-python
-
bug feat-prompt-management sdk-python
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
langfuse/langfuse-python#1976 ·
Los mantenedores suelen responder en 1 día
-
bug: LANGFUSE_MAX_EVENT_SIZE_BYTES is parsed but never enforced for score eventsPosiblemente ocupada @hassiebp la tomó hace 2 días. Abiertobug feat-scores sdk-python
langfuse/langfuse-python#1966 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
bug: non-numeric status in a 207 error entry raises inside handle_exception, kills the score consumer thread, flush()/shutdown() then hangPosiblemente ocupada @hassiebp la tomó hace 2 días. Abierto[Integrations] Language Clients bug feat-scores sdk-python
langfuse/langfuse-python#1967 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
bug: Partial-failure (207) ingestion response retries the whole batch up to 3x; per-item error details only logged at DEBUGPosiblemente ocupada @hassiebp la tomó hace 2 días. Abiertobug feat-ingestion
langfuse/langfuse-python#1965 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
bug: GCS upload detection in MediaManager uses substring match on the full URLPosiblemente ocupada @hassiebp la tomó hace 10 días. Abiertobug feat-multimodal-media sdk-python
langfuse/langfuse-python#1913 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de langfuse/langfuse-python
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 83/100
PedestrianDynamics/pyFDS-Evac#766 ·
Los mantenedores suelen responder en 1 día
-
Markdown tables render as literal text in 3 example files (missing blank line before header)Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 91/100
alchaincyf/nuwa-skill#86 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 2 días
-
Docs Needs Triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
pandas-dev/pandas#71055 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: graphify reads files that git's global ignore file hidesPosiblemente ocupada @smngvlkz la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Graphify-Labs/graphify#4335 · 1 comentario ·
Los mantenedores suelen responder en 1 día