Suppress "Placeholders have not been resolved" warning when MessagesPlaceholder use is intentional (LangChain integration)
Mantenedores costumam responder em até 1 dia
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Summary
ChatPromptClient.compile() (and get_langchain_prompt() which calls it
under the hood) unconditionally logs:
Placeholders ['...'] have not been resolved. Pass them as keyword arguments to compile().
even when leaving placeholders unresolved is intentional — i.e. the
caller follows the officially documented LangChain integration pattern
where unresolved placeholders are deliberately returned as
MessagesPlaceholder for LangChain's ChatPromptTemplate to resolve at
.invoke() time.
Result: production logs are flooded with one WARNING per request, masking
real signals.
Reproduction (langfuse 4.6.1, official docs example)
from langfuse import get_client
from langchain_core.prompts import ChatPromptTemplate
langfuse = get_client()
# Create a chat prompt with a placeholder (per docs example)
langfuse.create_prompt(
name="movie-critic-chat",
type="chat",
prompt=[
{"role": "system", "content": "You are an expert movie critic"},
{"type": "placeholder", "name": "chat_history"},
{"role": "user", "content": "What should I watch next?"},
],
labels=["production"],
)
# Documented LangChain integration:
# https://langfuse.com/docs/prompt-management/features/message-placeholders
prompt = langfuse.get_prompt("movie-critic-chat")
langchain_prompt = ChatPromptTemplate.from_template(prompt.get_langchain_prompt())
# → logs WARNING: Placeholders ['chat_history'] have not been resolved.
# even though leaving it unresolved is EXACTLY what the docs tell you
# to do for LangChain integration.
Why this is a problem
- The docs at
/docs/prompt-management/features/message-placeholders
(LangChain Python tab) endorse this exact pattern —MessagesPlaceholder
objects in the output are the documented goal. - SDK can't distinguish "intentional unresolved (LangChain hand-off)" from
"misuse (forgot kwargs)" and warns in both cases. - No public API to silence: no
silent=/suppress_warnings=kwarg on
compile()orget_langchain_prompt(). logging.getLogger("langfuse").setLevel(...)is not a reliable
workaround — see langfuse/langfuse#4976 reporting setLevel doesn't
affect certain SDK-emitted warnings.- Forces every LangChain integrator to install a
logging.Filterthat
string-matches the warning message — brittle (breaks on copy edits)
and easy to over-silence.
Suggested fix
Add a silent=True (or suppress_unresolved_warning=True) kwarg to:
ChatPromptClient.compile(**kwargs, silent: bool = False)ChatPromptClient.get_langchain_prompt(**kwargs, silent: bool = False)
When silent=True, the
"Placeholders ['...'] have not been resolved" warning is skipped, but
other validation warnings (e.g. "Placeholder X must contain a list of
chat messages") still fire — those are genuine misuse signals.
Alternatively, get_langchain_prompt() could pass silent=True to its
internal compile() call by default, since by definition any unresolved
placeholder returned from this method is intended for LangChain.
Version info
- langfuse-python: 4.6.1 (also reproduces on 4.5.1 + main
HEAD) - langchain-core: 1.3.2
- Python: 3.11
Current workaround we use
contextlib.contextmanager that scopes a logging.Filter matching the
substring "have not been resolved" over the
chat_skeleton.get_langchain_prompt() call site. Fragile (depends on
warning string), but scoped narrowly so other langfuse warnings still
propagate.
Happy to send a PR if the maintainers agree with the kwarg shape.
- Linguagem predominante
- Python
- Estrelas
- 498
- Forks
- 361
- Merge médio
- 16h 40min
- PRs com merge (30d)
- 38
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de langfuse/langfuse-python
-
bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder itemTalvez já em andamento @hassiebp assumiu hoje. Abertabug feat-prompt-management sdk-python
langfuse/langfuse-python#1971 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
bug: LANGFUSE_MAX_EVENT_SIZE_BYTES is parsed but never enforced for score eventsTalvez já em andamento @hassiebp assumiu hoje. Abertabug feat-scores sdk-python
langfuse/langfuse-python#1966 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
bug: non-numeric status in a 207 error entry raises inside handle_exception, kills the score consumer thread, flush()/shutdown() then hangTalvez já em andamento @hassiebp assumiu hoje. Aberta[Integrations] Language Clients bug feat-scores sdk-python
langfuse/langfuse-python#1967 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
bug: Partial-failure (207) ingestion response retries the whole batch up to 3x; per-item error details only logged at DEBUGTalvez já em andamento @hassiebp assumiu hoje. Abertabug feat-ingestion
langfuse/langfuse-python#1965 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
bug: GCS upload detection in MediaManager uses substring match on the full URLTalvez já em andamento @hassiebp assumiu há 9 dias. Abertabug feat-multimodal-media sdk-python
langfuse/langfuse-python#1913 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de langfuse/langfuse-python
Issues semelhantes
-
Performance: deprecated DeviceEntry.config_entries access blocks the event loop for tens of secondsAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
tuya/tuya_cloud_ha_bridge#14 ·
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
semantica-agi/semantica#1968 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia
-
agent: ready area: submission priority: high type: docs
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
dkritarth/scopewatch#213 ·
Mantenedores costumam responder em até 1 dia
-
Broken link in RELEASE.mdTalvez já em andamento @Jah-yee assumiu hoje. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
sphinx-contrib/httpdomain#143 ·
Mantenedores costumam responder em até 1 dia