Suppress "Placeholders have not been resolved" warning when MessagesPlaceholder use is intentional (LangChain integration)
维护者通常 1 天内回复
@hassiebp 已经在做这个了。
开始于 2026年5月22日。
评估
这个 Issue 还没有评估数据。
描述
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.
- 主要语言
- Python
- 星标
- 495
- 派生
- 358
- 平均合并
- 16 小时 54 分钟
- 30 天内合并 PR
- 20
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
langfuse/langfuse-python 的其他 Issue
-
bug: GCS upload detection in MediaManager uses substring match on the full URL可能已有人在做 @hassiebp 今天认领。 未关闭bug feat-multimodal-media sdk-python
langfuse/langfuse-python#1913 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
bug: get_dataset_run / get_dataset_runs / delete_dataset_run are unusable on Langfuse v4可能已有人在做 @hassiebp 于 3 天前认领。 未关闭bug feat-datasets feat-experiments sdk-python
langfuse/langfuse-python#1906 · 已指派 1 人 ·
维护者通常 1 天内回复
-
mask is not applied to create_dataset_item or create_score(comment=)可能已有人在做 @hassiebp 于 7 天前认领。 未关闭bug compliance feat-data-masking sdk-python security
langfuse/langfuse-python#1896 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Scores bypass sample_rate since v4可能已有人在做 @hassiebp 于 12 天前认领。 未关闭feat-scores sdk-python unconfirmed-bug
langfuse/langfuse-python#1890 · 已指派 1 人 ·
维护者通常 1 天内回复
-
batch_evaluation fails on self-hosted v4 events_only deployments (uses unavailable v3 read endpoints)可能已有人在做 @hassiebp 于 25 天前认领。 未关闭bug feat-evals sdk-python
langfuse/langfuse-python#1861 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 langfuse/langfuse-python 的全部 Issue
相似的 Issue
-
bug server
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
sportsdataverse/sportsdataverse-py#641 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
googleapis/google-cloud-python#18532 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复